Custom meta field doesnt showing

[ad_1]

I tried this code:

//invoice

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="order_jmeno_ucastnika1";
    $location = $item['product']->get_meta($field_name,true,'edit');
    if (!empty($location)) {
        echo '<div class="product-location">Location: '.$location.'</div>';
    }
}

Also this code:

add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_my_custom_field', 10, 2 );
function wpo_wcpdf_my_custom_field ($template_type, $order) {
    if ($template_type == 'invoice') {
        ?>
        <tr class="order_jmeno_ucastnika1">
        <th>Custom Field:</th>
        <td><?php echo $order->get_meta('order_jmeno_ucastnika1'); ?></td>
        </tr>
        <?php
    }
}

But nothing showed. I have also PRO version of plugin. I need show this field in invoice with condition, when is in order virtual product.

It can be displayed under product in invoice, but also under billing informations.

  • This topic was modified 2 hours, 9 minutes ago by koupmi.
  • This topic was modified 2 hours, 8 minutes ago by koupmi.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer