Cannot get custom field to display in invoice template
-
I’ve added a custom field using this method. Using the WooCommerce Store Toolkit plugin, I can see my custom field under the Product Post Meta. There it shows “_hscode” along with the value I entered for the product.
I’ve created a custom invoice template, and tried adding the code as you recommend, so I have:
<?php $this->custom_field('_hscode'); ?>
Yet still nothing shows up on my invoice. I’m not well versed in php though, so maybe I’m making a simple error somewhere. Here’s a fuller picture of what I’ve done in my custom template:
<span class="item-meta"><?php echo $item['meta']; ?></span> <dl class="meta"> <?php $description_label = __( 'SKU', 'woocommerce-pdf-invoices-packing-slips' ); // registering alternate label translation ?> <?php if( !empty( $item['sku'] ) ) : ?><dt class="sku"><?php _e( 'SKU:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="sku"><?php echo $item['sku']; ?></dd><?php endif; ?> <?php if( !empty( $item['weight'] ) ) : ?><dt class="weight"><?php _e( 'Weight:', 'woocommerce-pdf-invoices-packing-slips' ); ?></dt><dd class="weight"><?php echo $item['weight']; ?><?php echo get_option('woocommerce_weight_unit'); ?><?php endif; ?>. HS Code: <?php $this->custom_field('_hscode'); ?></dd> </dl> <?php do_action( 'wpo_wcpdf_after_item_meta', $this->type, $item, $this->order ); ?>
We want the HS Code (_hscode) to show up on the same line as the Weight, under each product.
Any help would be much appreciated.
- The topic ‘Cannot get custom field to display in invoice template’ is closed to new replies.