Need to display “product custom fields”
-
Im using ACF-plugin to show a custom text on the product page showing the warrenty of the product. I would like to show that on the packing slips and invoices as well.
I have looked at this link: “https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/displaying-product-custom-fields/” and that seems like the thing i am looking for, but when i change the name ‘locations’ from the example, to my custom field name, it doesn’t seem to work?
The name of my ACF custom field is ‘garantier’
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 = 'garantier'; $location = 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($location)) { echo '<div class="product-location">Location: '.$location.'</div>'; } }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Need to display “product custom fields”’ is closed to new replies.