title: Get product custom field values as variables in WooCommerce
body: <p>I am using Woocommerce for registration for classes; each class/product has up to 20 custom fields, which I need to return as variables in order to highly customize the checkout and order details pages and customer email template. </p>
  
  <p>I <strong>don't</strong> just want to add all of the custom meta data with hooks, because I need very tight control over the output. For instance, the following answer worked fine for including custom fields in the cart page:  <a href="https://stackoverflow.com/questions/43893196/display-custom-fields-value-in-woocommerce-cart-checkout-items/43898948#43898948">Display Custom Field&#39;s Value in Woocommerce Cart &amp; Checkout items</a></p>
  
  <p>But I would like them in checkout, order details and emails as well, with full control over the HTML where they appear <em>(in some cases they will need to be converted as well, e.g., Unix timestamps to human readable time)</em>.</p>
  
  <p>In <code>order-item-details.php</code> template I have tried the following:</p>
  
  <pre><code>$room = get_post_meta( $product-&gt;ID, 'room', true );
  $room_number = get_post_meta( $product-&gt;ID, 'room_number', true );
  $instructor = get_post_meta( $product-&gt;ID, 'instructor', true );
  
  echo 'Your instructor is ' . $instructor . '.';
  echo 'Your class is in ' . $room . '.';
  </code></pre>
  
  <p>But it didn't work…</p>
  
  <p>How can I access and use custom field values associated with a specific product?</p>