Extra Custom Fields
-
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
- The topic ‘Extra Custom Fields’ is closed to new replies.