Custom field on packing slip for certain products only
-
Hi, I’m using some custom fields that only display if you are purchasing a certain product and have used the code provided from your support docs at the link below which works fine however it displays the H3 text on all packing slips where I would like it to hide the html/H3 text if the custom field doesn’t exist for a product.
I’ve tried to look for a solution on this support forum and can see similar ones where fields don’t show if no data exists using “if (empty…” or similar but I can’t seem to work that code into the code below.
If anyone could help I’d really appreciate it.
Many thanks in advance!
https://docs.wpovernight.com/woocommerce-pdf-invoices-packing-slips/displaying-a-custom-field/
add_action( 'wpo_wcpdf_after_order_details', 'wpo_wcpdf_funeral_start_time', 10, 2 ); function wpo_wcpdf_funeral_start_time ($template_type, $order) { $document = wcpdf_get_document( $template_type, $order ); if ($template_type == 'packing-slip') { ?> <div> <h3>Funeral start time:</h3> <p><?php $document->custom_field('funeral_start_time'); ?></p> <p></p> </div> <?php } }
- The topic ‘Custom field on packing slip for certain products only’ is closed to new replies.