title: Show multiple product custom fields values in cart on Woocommerce
body: <p>I have a problem with custom fields &amp; values from my product page appearing on the cart page. As you can see from the screenshots, I have three fields: "Color," "Texto1" and "Texto2" and only the first seems to appear on my cart page.</p>
  
  <p>This is the code that print the fields on the product page:    </p>
  
  <pre><code>// Field 1
  if( ! empty( $FieldType1 ) ){
      if( $FieldType1 == "TEXT AREA"){
      echo '&lt;div&gt;
          &lt;label&gt;'.$FieldName1.':&lt;br&gt;&lt;/label&gt; &lt;textarea name="FieldTypeValue1" maxlength="'.$FieldLenght1.'" rows="2" cols="80" placeholder="" required&gt;&lt;/textarea&gt;
      &lt;/div&gt;&lt;br&gt;';
      }
  
      if( $FieldType1 == "TEXT BOX"){
      echo '&lt;div&gt;
          &lt;label&gt;'.$FieldName1.':&lt;br&gt;&lt;/label&gt; &lt;input type="text"  maxlength="'.$FieldLenght1.'" name="FieldTypeValue1" value="" required&gt;
      &lt;/div&gt;&lt;br&gt;';
      }
  
      if( $FieldType1 == "DROP DOWN"){
          echo '&lt;div&gt;
          &lt;label&gt;'.$FieldName1.':&lt;br&gt;&lt;/label&gt;
          &lt;select name="FieldTypeValue1"&gt;';
          foreach ($Dropdown1Content as $Dropdown1IndividualContent) {
          echo '&lt;option&gt;';
          echo $Dropdown1IndividualContent;
          echo '&lt;/option&gt;';
          }
  
          echo '&lt;/select&gt;&lt;/div&gt;&lt;br&gt;';
      }
  }
  
  // Field 2  
  if( ! empty( $FieldType2 ) ){
      if( $FieldType2 == "TEXT AREA"){
      echo '&lt;div&gt;
          &lt;label&gt;'.$FieldName2.':&lt;br&gt;&lt;/label&gt; &lt;textarea name="FieldTypeValue2" maxlength="'.$FieldLenght2.'" rows="2" cols="80" placeholder="" required&gt;&lt;/textarea&gt;
      &lt;/div&gt;&lt;br&gt;';
      }
  
      if( $FieldType2 == "TEXT BOX"){
      echo '&lt;div&gt;
          &lt;label&gt;'.$FieldName2.':&lt;br&gt;&lt;/label&gt; &lt;input type="text"  maxlength="'.$FieldLenght2.'" name="FieldTypeValue2" value="" required&gt;
      &lt;/div&gt;&lt;br&gt;';
      }
  
      if( $FieldType2 == "DROP DOWN"){
          echo '&lt;div&gt;
          &lt;label&gt;'.$FieldName2.':&lt;br&gt;&lt;/label&gt;
          &lt;select name="FieldTypeValue2"&gt;';
          foreach ($Dropdown2Content as $Dropdown2IndividualContent) {
          echo '&lt;option&gt;';
          echo $Dropdown2IndividualContent;
          echo '&lt;/option&gt;';
          }
  
          echo '&lt;/select&gt;&lt;/div&gt;&lt;br&gt;';
      }
  }
  
  
  
  // Field 3
  if( ! empty( $FieldType3 ) ){
      if( $FieldType3 == "TEXT AREA"){
      echo '&lt;div&gt;
          &lt;label&gt;'.$FieldName3.':&lt;br&gt;&lt;/label&gt; &lt;textarea name="FieldTypeValue3" maxlength="'.$FieldLenght3.'" rows="2" cols="80" placeholder="" required&gt;&lt;/textarea&gt;
      &lt;/div&gt;&lt;br&gt;';
      }
  
      if( $FieldType3 == "TEXT BOX"){
      echo '&lt;div&gt;
          &lt;label&gt;'.$FieldName3.':&lt;br&gt;&lt;/label&gt; &lt;input type="text"  maxlength="'.$FieldLenght3.'" name="FieldTypeValue3" value="" required&gt;
      &lt;/div&gt;&lt;br&gt;';
      }
  
      if( $FieldType3 == "DROP DOWN"){
          echo '&lt;div&gt;
          &lt;label&gt;'.$FieldName3.':&lt;br&gt;&lt;/label&gt;
          &lt;select name="FieldTypeValue3"&gt;';
          foreach ($Dropdown3Content as $Dropdown3IndividualContent) {
          echo '&lt;option&gt;';
          echo $Dropdown3IndividualContent;
          echo '&lt;/option&gt;';
          }
  
          echo '&lt;/select&gt;&lt;/div&gt;&lt;br&gt;';
      }
  }
  </code></pre>
  
  <p>This is the code that saves the value of the fields on the product page</p>
  
  <pre><code>// Store custom field label and value in cart item data
  add_action( 'woocommerce_add_cart_item_data','save_my_custom_checkout_field', 10, 2 );
  function save_my_custom_checkout_field( $cart_item_data, $product_id ) {
  if( isset( $_REQUEST['FieldTypeValue1'] ) ) {
      $cart_item_data['custom_data']['label'] = get_post_meta($product_id, 'FieldName1', true);
      $cart_item_data['custom_data']['value'] = sanitize_text_field( $_REQUEST['FieldTypeValue1'] );
      $cart_item_data['custom_data']['ukey'] = md5( microtime().rand() );
  }
  return $cart_item_data;
  
  if( isset( $_REQUEST['FieldTypeValue2'] ) ) {
      $cart_item_data['custom_data']['label'] = get_post_meta($product_id, 'FieldName2', true);
      $cart_item_data['custom_data']['value'] = sanitize_text_field( $_REQUEST['FieldTypeValue2'] );
      $cart_item_data['custom_data']['ukey'] = md5( microtime().rand() );
  }
  return $cart_item_data;
  
  if( isset( $_REQUEST['FieldTypeValue3'] ) ) {
      $cart_item_data['custom_data']['label'] = get_post_meta($product_id,'FieldName3', true);
      $cart_item_data['custom_data']['value'] = sanitize_text_field( $_REQUEST['FieldTypeValue3'] );
      $cart_item_data['custom_data']['ukey'] = md5( microtime().rand() );
  }
  return $cart_item_data;
  </code></pre>
  
  <p>And this is the one that print the values on the cart:</p>
  
  <pre><code>// Display items custom fields label and value in cart and checkout pages
  add_filter( 'woocommerce_get_item_data', 'render_meta_on_cart_and_checkout', 10, 2 );
  function render_meta_on_cart_and_checkout( $cart_data, $cart_item ){
  
  $custom_items = array();
  
  /* Woo 2.4.2 updates */
  if( !empty( $cart_data ) ) {
      $custom_items = $cart_data;
  }
  if( isset( $cart_item['custom_data'] ) ) {
      $custom_items[] = array(
          'name' =&gt; $cart_item['custom_data']['label'],
          'value' =&gt; $cart_item['custom_data']['value'],
      );
  }
  return $custom_items;
  
  }
  </code></pre>
  
  <p>The Custom fields on product page: </p>
  
  <p><img src="https://i.stack.imgur.com/CKkT4.png" alt="Product page"></p>
  
  <p>The product in cart (with the missing data): </p>
  
  <p><img src="https://i.stack.imgur.com/Dhs3B.png" alt="Product in cart"></p>
  
  <p>I'm not sure if the problem is at the point where values are saved or at the point where they are printed.</p>
  
  <p>Any help would be much appreciated.</p>