title: Adding checkboxes to variation products admin meta woocommerce
body: <p>Respectfully had to ask this question again due to it being closed and linked to a question that had little reference to my problem and was more about field creation.</p>
  <p>How do I add custom fields (multiple checkboxes) to a WooCommerce variable product in product admin as checkboxes that adds meta only if checked and saves as admin only?</p>
  <p>Please understand adding the fields is complete but the question relates to me needing the checkbox to only add meta when checked and how to hide the meta not the creation of the fields that part is done.</p>
  <p><strong>This display code functions well inside my variation</strong></p>
  <pre><code>add_action( 'woocommerce_product_after_variable_attributes', 'variation_settings_fields', 10, 3 );
      
      function variation_settings_fields( $loop, $variation_data, $variation ) {
          woocommerce_wp_text_input(
            array(
                'id'            =&gt; &quot;bin_location{$loop}&quot;,
                'name'          =&gt; &quot;bin_location[{$loop}]&quot;,
                'value'         =&gt; get_post_meta( $variation-&gt;ID, 'bin_location', true ),
                'label'         =&gt; __( 'Bin Location', 'woocommerce' ),
                'desc_tip'      =&gt; true,
                'description'   =&gt; __( 'Some description.', 'woocommerce' ),
                'wrapper_class' =&gt; 'form-row form-row-full',
            )
          );
          woocommerce_wp_checkbox(
            array(
              'id'            =&gt; &quot;licence_mcps{$loop}&quot;,
              'name'          =&gt; &quot;licence_mcps[{$loop}]&quot;,
              'value'         =&gt; get_post_meta( $variation-&gt;ID, 'licence_mcps', true ),
              'label'         =&gt; __( 'MCPS', 'woocommerce' ),
              'desc_tip'    =&gt; true,
              'description' =&gt; __( &quot;MCPS Product&quot;, &quot;woocommerce&quot; )
            )
          );
          woocommerce_wp_checkbox(
            array(
              'id'            =&gt; &quot;licence_ppl{$loop}&quot;,
              'name'          =&gt; &quot;licence_ppl[{$loop}]&quot;,
              'value'         =&gt; get_post_meta( $variation-&gt;ID, 'licence_ppl', true ),
              'label'         =&gt; __( 'PPL', 'woocommerce' ),
              'desc_tip'    =&gt; true,
              'description' =&gt; __( &quot;PPL Product&quot;, &quot;woocommerce&quot; )
            )
          );
        }
  </code></pre>
  <p><strong>This code functions but would prefer the checkbox only to add meta if checked on yes, is it possible to only add meta if the checkbox is checked</strong></p>
  <pre><code>    add_action( 'woocommerce_save_product_variation', 'save_variation_settings_fields', 10, 2 );
      function save_variation_settings_fields( $variation_id, $loop ) {
      $bin_loc = $_POST['bin_location'][ $loop ];
      $mcps_prod = $_POST['licence_mcps'][ $loop ];
      $ppl_prod = $_POST['licence_ppl'][ $loop ];
     
      if( isset( $bin_loc ) ) 
          update_post_meta( $variation_id, 'bin_location', esc_attr( $bin_loc )); 
    
      $mcps_checkbox = isset( $mcps_prod ) ? 'yes' : ' ';
       update_post_meta( $variation_id, 'licence_mcps', $mcps_checkbox );
  
      $ppl_checkbox  = isset( $ppl_prod ) ? 'yes' : ' ';
       update_post_meta( $variation_id, 'licence_ppl', $ppl_checkbox );
       
  }
  </code></pre>
  <p><strong>And this does not hide the meta how do i hide this apart from in order admin</strong></p>
  <pre><code>add_action('woocommerce_checkout_create_order_line_item', 'save_file_type_as_order_item_meta', 20, 4);
  function save_file_type_as_order_item_meta($item, $cart_item_key, $values, $order) {
      if ( $licence_mcps = $values['data']-&gt;get_meta('licence_mcps') ) {
          $item-&gt;update_meta_data( 'licence_mcps', $licence_mcps ); 
      }
      if ( $bin_location = $values['data']-&gt;get_meta('bin_location') ) {
        $item-&gt;update_meta_data( 'bin_location', $bin_location ); 
      }
      if ( $licence_ppl = $values['data']-&gt;get_meta('licence_ppl') ) {
        $item-&gt;update_meta_data( 'licence_ppl', $licence_ppl ); 
      }
  }
  </code></pre>