title: Woocommerce Products Custom Field
body: <p>I have added custom fields to my woocommerce products and have been able to enter and fill the custom field data on products.  I am trying now to use the data from that custom field in a button I am adding on the woocommerce single product page.</p>
  
  <p>The custom field is a URL for the product sample.  I am then trying to add a "View Product Sample" button on the woocommerce single product page that navigates to the url entered int he custom field.  Here is the code I have:</p>
  
  <pre><code>// Display Fields
  add_action( ‘woocommerce_product_options_general_product_data’, ‘woo_add_custom_general_fields’ );
  
  // Save Fields
  add_action( ‘woocommerce_process_product_meta’, ‘woo_add_custom_general_fields_save’ );
  
  function woo_add_custom_general_fields() {
  
  global $woocommerce, $post;
  
  // Text Field
  woocommerce_wp_text_input(
  array(
  ‘id’ =&gt; ‘product_sample’,
  ‘label’ =&gt; __( ‘Sample Product Link’, ‘woocommerce’ ),
  ‘placeholder’ =&gt; ‘http://’,
  ‘desc_tip’ =&gt; ‘true’,
  ‘description’ =&gt; __( ‘Enter the sample product link here.’, ‘woocommerce’ )
  )
  );
  }
  function woo_add_custom_general_fields_save( $post_id ){
  
  // Textfield
  $woocommerce_text_field = $_POST[‘product_sample’];
  if( !empty( $woocommerce_text_field ) )
  update_post_meta( $post_id, ‘product_sample’, esc_html( $woocommerce_text_field ) );
  
  }
  
  add_action(‘woocommerce_after_add_to_cart_button’,’cmk_additional_button’);
  function cmk_additional_button() {
  
   echo '&lt;a href="CONTENT OF CUSTOM FIELD - URL" target="_blank" button 
  type="submit" class="button sample"&gt;View Product Sample&lt;/a&gt;';
  
  }
  </code></pre>
  
  <p>I need help determining how to get my custom field meta data into the link for the button that is echoed at the end of the code.</p>
  
  <p>Thanks for any help anyone can give.</p>