Add custom field to invoice

[ad_1]

Hi,

I'm using this plugin to add custom fields "WooCommerce Checkout Manager" and I've added to the checkout billing fields a few custom fields that show the name of the company, company ID, and 2 other fields. I want those fields to be displayed in the Invoice, but the only output I'm getting is the Label, and the values are not shown. 

All the custom fields are hidden until the answer to a previous question is yes, but in my testing the answer in the order was yes and all the custom fields were fulfilled. In that case I would like also to know if it's possible to hide those fields in the invoice if the answer is No or if the fields are empty.

This is the code I'm using:
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_service_charge', 10, 2 );
function wpo_wcpdf_service_charge ($template_type, $order) {
        ?>      
        <tr class="billing_wooccm13">
            <th>Company:</th>
            <td><?php $order->get_meta('billing_wooccm13'); ?></td>
        </tr>
        <?php
    
}
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_service_charge', 10, 2 );
function wpo_wcpdf_service_charge ($template_type, $order) {
        ?>      
        <tr class="billing_wooccm10">
            <th>Company ID:</th>
            <td><?php $order->get_meta('billing_wooccm10'); ?></td>
        </tr>
        <?php
    
}
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_service_charge', 10, 2 );
function wpo_wcpdf_service_charge ($template_type, $order) {
        ?>      
        <tr class="billing_wooccm11">
            <th>SSa:</th>
            <td><?php $order->get_meta('billing_wooccm11'); ?></td>
        </tr>
        <?php
    
}
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_service_charge', 10, 2 );
function wpo_wcpdf_service_charge ($template_type, $order) {
        ?>      
        <tr class="billing_wooccm12">
            <th>SSb:</th>
            <td><?php $order->get_meta('billing_wooccm12'); ?></td>
        </tr>
        <?php
    
}

 

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