• gilesytheking

    (@gilesytheking)


    I would like to add VAT number to invoices underneath the customer billing address details.

    I have tried using your code snippet from FAQ section to add VAT number, but the code breaks my site.

    The plugin I use for VAT numbers store them in the DB using the _vat_number meta key

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author priyankajagtap

    (@priyankajagtap)

    Hi @gilesytheking,

    I apologize for the late response. We were on holidays due to the Diwali festival here in India hence the delay caused in replying to you.

    Thank you for sharing the site URL. We have checked the code snippet provided in the FAQ section on our plugin page and noticed that there is a need to make the slight modification in the code. Here, is the updated code which you can add in your active theme’s functions.php file.

    Code:

    function example_custom_order_fields( $fields, $order ) {
        $new_fields = array();
    
        if( get_post_meta( $order->get_id(), '_vat_number', true ) ) {
            $new_fields['_vat_number'] = array( 
                'label' => 'VAT',
                'value' => get_post_meta( $order->get_id(), '_vat_number', true )
            );
        }
        return array_merge( $fields, $new_fields );
    }
    add_filter( 'wcdn_order_info_fields', 'example_custom_order_fields', 10, 2 );

    This will add the VAT number in the table above the Product details: https://prnt.sc/lioow9

    Once you have added the above code, please check and let us know whether it is working as per your requirement or not.

    Regards,
    Priyanka Jagtap

Viewing 1 replies (of 1 total)
  • The topic ‘Adding VAT number under customer Billing Address details’ is closed to new replies.