Title: Extra Custom Fields
Last modified: January 22, 2021

---

# Extra Custom Fields

 *  Resolved [vierthom](https://wordpress.org/support/users/vierthom/)
 * (@vierthom)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/extra-custom-fields-3/)
 * Hi Ewout, what a great plugin! thank you.
    I was able to add extra custom fields
   to the invoice by adding the snippet:
 * // add additional product attributes to invoice HS TARIFF CODE
 * add_action( ‘wpo_wcpdf_after_item_meta’, ‘wpo_wcpdf_product_custom_field’, 10,
   3 );
    function wpo_wcpdf_product_custom_field ( $template_type, $item, $order){//
   check if product exists first if (empty($item[‘product’])) return;
 *  // replace ‘Location’ with your custom field name!
    $field_name = ‘hstariff’;
   $hstariff = $item[‘product’]->get_meta($field_name,true,’edit’); if (!empty($
   hstariff)) { echo ‘<div class=”product-location”>HS Tariff Code: ‘.$hstariff.'
   </div>’; } // replace ‘Location’ with your custom field name! $field_name = ‘
   country_origin’; $country_origin = $item[‘product’]->get_meta($field_name,true,’
   edit’); if (!empty($country_origin)) { echo ‘<div class=”product-location”>Country
   of Origin: ‘.$country_origin.'</div>’; } }
 * But this extra lines are in a different font and fontsize than the SKU and Weight
   information just above these lines. You must have a trick to get it all in the
   same font?
 * Thomas

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

 *  Plugin Contributor [Yordan Soares](https://wordpress.org/support/users/yordansoares/)
 * (@yordansoares)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/extra-custom-fields-3/#post-13945016)
 * Hello [@vierthom](https://wordpress.org/support/users/vierthom/),
 * Try this code instead:
 *     ```
       // Custom Fields
       add_action( 'wpo_wcpdf_after_item_meta', 'wpo_wcpdf_product_custom_field', 10, 3 );
       function wpo_wcpdf_product_custom_field ( $template_type, $item, $order ) {
         // check if product exists first
         if (empty($item['product'])) return;
   
         // Display 'hstariff' if exists
         $field_name = 'hstariff';
       	$hstariff = $item['product']->get_meta($field_name,true,'edit');	
         if (!empty($hstariff)) {
           echo '<div class="hstariff">HS Tariff Code: '.$hstariff.'</div>';
         }
         // Display 'country_origin' if exists
         $field_name = 'country_origin';
       	$country_origin = $item['product']->get_meta($field_name,true,'edit');	
         if (!empty($country_origin)) {
           echo '<div class="country-origin">Country of Origin: '.$country_origin.'</div>';
         }
       }
   
       // Styles
       add_action( 'wpo_wcpdf_custom_styles', 'wpo_wcpdf_custom_styles', 10, 2 );
       function wpo_wcpdf_custom_styles ( $document_type, $document ) {
           ?>
           div.hstariff,
           div.country-origin {
               font-size: 7pt;
           }
           <?php
       }
       ```
   
 * See also [Using custom styles](https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/using-custom-styles/).
 * Let me know if work!
 *  Thread Starter [vierthom](https://wordpress.org/support/users/vierthom/)
 * (@vierthom)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/extra-custom-fields-3/#post-13945399)
 * Works like a charm! thank you.

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

The topic ‘Extra Custom Fields’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [vierthom](https://wordpress.org/support/users/vierthom/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/extra-custom-fields-3/#post-13945399)
 * Status: resolved