Cannot Display Custom Meta Data on Items
-
So I have a client who’s using woocommerce to send them orders for glasses prescriptions. There’s only 1 product but it has custom meta each time. I have it working on everything else on the site but not on the PDF. When I try to use any of the methods outlined in your documentation they either show up blank or throw an error. Here’s my custom function:
add_filter( 'wpo_wcpdf_before_item_meta', 'wpo_wcpdf_add_meta', 10, 3 ); function wpo_wcpdf_add_meta ($template_type, $item, $order) { // check if product exists first if (empty($item['product'])) return; $document = wcpdf_get_document( $template_type, $order, $item ); if ($template_type == 'invoice') { ?> <h3>Frame Info</h3> <table class="order-info" style="width:100%;"> <?php if (!empty($item['product'])) { $field_name = '_frame_name'; $frameName = 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($frameName) ) { echo '<div class="product-location">Frame Name: '.$frameName.'</div>'; } } ?> </table> <?php } }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Cannot Display Custom Meta Data on Items’ is closed to new replies.