Title: Cannot Display Custom Meta Data on Items
Last modified: April 9, 2020

---

# Cannot Display Custom Meta Data on Items

 *  Resolved [starfiredev](https://wordpress.org/support/users/starfiredev/)
 * (@starfiredev)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/cannot-display-custom-meta-data-on-items/)
 * So I have a client who’s using woocommerce to send them orders for glasses prescriptions.
   There’s only 1 product but it has custom meta each time. I have it working on
   everything else on the site but not on the PDF. When I try to use any of the 
   methods outlined in your documentation they either show up blank or throw an 
   error. Here’s my custom function:
 *     ```
       add_filter( 'wpo_wcpdf_before_item_meta', 'wpo_wcpdf_add_meta', 10, 3 );
       function wpo_wcpdf_add_meta ($template_type, $item, $order) {
           // check if product exists first
           if (empty($item['product'])) return;
   
           $document = wcpdf_get_document( $template_type, $order, $item );
           if ($template_type == 'invoice') {
   
   
   
               ?>      
   
               <h3>Frame Info</h3>
               <table class="order-info" style="width:100%;">
   
                   <?php
                   if (!empty($item['product'])) {
                       $field_name = '_frame_name';
                       $frameName = method_exists($item['product'], 'get_meta') ? $item['product']->get_meta($field_name,true,'edit') : get_post_meta( $item['product']->id, $field_name, true );
                       if ( !empty($frameName) ) {
                           echo '<div class="product-location">Frame Name: '.$frameName.'</div>';
                       }
                   }
                   ?>
   
               </table>
   
               <?php
   
               }
           }
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/cannot-display-custom-meta-data-on-items/#post-12652959)
 * The reason this throws an error is probably because your HTML formatting is off,
   you’re creating a table without cells but with a stray div in it:
 *     ```
       <table class="order-info" style="width:100%;">
           <div class="product-location">Frame Name: xxxxxxxxx</div>
       </table>
       ```
   
 * This will probably work if you remove the table element from your code (or make
   it a div element, or put your `.product-location` in a `<tr><td>...</td></tr>`.
 *  Thread Starter [starfiredev](https://wordpress.org/support/users/starfiredev/)
 * (@starfiredev)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/cannot-display-custom-meta-data-on-items/#post-12653240)
 * My apoligies, I was more concerned about getting the data to work first and then
   make it look nice.
 * I’ve cleaned up the code a bit. It doesn’t throw any errors but it does list 
   Manufacturer as blank on the PDF:
 *     ```
       add_action( 'wpo_wcpdf_before_item_meta', 'wpo_wcpdf_add_meta', 10, 3 );
       function wpo_wcpdf_add_meta ($template_type, $item, $order) {
           // check if product exists first
           if (empty($item['product'])) return;
   
           $document = wcpdf_get_document( $template_type, $order, $item );
           //print_r($order);
           if ($template_type == 'invoice') {        
               $order_id = $order->get_meta('id');
               print_r($order_id);
               ?>      
               <h3>Frame Info</h3>
               <ul>
                   <?php
                       $frameManufacturer = $order->get_meta('_frame_manufacturer');
                       ?>
                       <li>Manufacturer: <?php echo($frameManufacturer)?></li>';
                   ?>
               </ul>
               <?php
               }
           }
       ```
   
 * I should also mention the data I’m trying to retrieve is in the item line’s meta
   data. When I printed the entire order array I did see my variables so there must
   be a way to display them.
    -  This reply was modified 6 years, 2 months ago by [starfiredev](https://wordpress.org/support/users/starfiredev/).
 *  Plugin Contributor [Ewout](https://wordpress.org/support/users/pomegranate/)
 * (@pomegranate)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/cannot-display-custom-meta-data-on-items/#post-12654354)
 * You have changed the function – the previous snippet pulled product meta:
 *     ```
       $item['product']->get_meta($field_name);
       ```
   
 * and the new one pulls order meta:
 *     ```
       $order->get_meta('_frame_manufacturer');
       ```
   
 * but you mention you need line item meta… that would be
 *     ```
       wc_get_order_item_meta( $item['item_id'], '_frame_manufacturer );
       ```
   
 *  Thread Starter [starfiredev](https://wordpress.org/support/users/starfiredev/)
 * (@starfiredev)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/cannot-display-custom-meta-data-on-items/#post-12656520)
 * That did it! Thank you so much!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Cannot Display Custom Meta Data on Items’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pdf-invoices-packing-slips/assets/icon-256x256.
   png?rev=2189942)
 * [PDF Invoices & Packing Slips for WooCommerce](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pdf-invoices-packing-slips/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [starfiredev](https://wordpress.org/support/users/starfiredev/)
 * Last activity: [6 years, 2 months ago](https://wordpress.org/support/topic/cannot-display-custom-meta-data-on-items/#post-12656520)
 * Status: resolved