• Hi,
    I need to put custom field which is choosed by customer in the checkout to the invoice under the billing address. Custom field name is ‘billing_agreenment”. I’ve read documentation about putting action hook to template and it’s working in packing slips when I put ‘billing_agreenment’ insted of ‘delivery date’ from sample but nothing is said about putting custom field to invoice. I’ve tried almost everything with changing template_type to ‘invoice’, etc.

    Here is template that I tried to modify:

    add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_delivery_date', 10, 2 );
    function wpo_wcpdf_delivery_date ($template_type, $order) {
        $document = wcpdf_get_document( $template_type, $order );
        if ($template_type == 'packing-slip') {
            ?>
            <tr class="delivery-date">
                <th>Delivery Date:</th>
                <td><?php $document->custom_field('delivery_date'); ?></td>
            </tr>
            <?php
        }
    }

    What do I have to change to work it on?
    Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! All you have to do is change packing-slip to invoice:

    
    add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_billing_agreement', 10, 2 );
    function wpo_wcpdf_billing_agreement ($template_type, $order) {
        $document = wcpdf_get_document( $template_type, $order );
        if ($template_type == 'invoice') {
            ?>
            <tr class="billing-agreement">
                <th>Billing Agreement:</th>
                <td><?php $document->custom_field('billing_agreenment'); ?></td>
            </tr>
            <?php
        }
    }
    

    Note that I have used billing_agreenment as mentioned in your post. You mentioned agreenment_choice in the post title and ‘agreement’ would be correct English, so you may want to double check on the fieldname. Whatever worked in the packing slip should work here as well though ??
    Ewout

Viewing 1 replies (of 1 total)
  • The topic ‘Custom filed ‘agreenment_choice’ by action hook in invoice template’ is closed to new replies.