• Resolved mielnikus

    (@mielnikus)


    Hi,

    Is it possible to show different Shop VAT numbers on the invoice, depending on client location ?

    For example company based in France has its French VAT number, but also is registered for VAT in Germany.

    For the clients from France, merchant VAT number on the invoice should be the one issued in France, but for the client coming from Germany, shops VAT number needs to be changed to the one issued in Germany.

Viewing 1 replies (of 1 total)
  • Plugin Contributor Darren Peyou

    (@dpeyou)

    Hi @mielnikus,

    It is possible to set different conditions based on the customer’s billing or shipping country, your code snippet would look something like this:

    add_filter( 'wpo_wcpdf_after_shop_address', 'wpo_wcpdf_conditional_vat_number', 10, 2 );
    function wpo_wcpdf_conditional_vat_number( $template_type, $order ) {
    	
    	// if order is empty, bail
    	if ( empty($order) ) {return;}
    	
    	$billing_country = $order->get_billing_country();
    
    	switch( $billing_country ) {
    		// UK VAT number
    		case "GB":
    			echo "GB123";
    		break;
    
    		// French VAT number
    		case "FR":
    			echo "France123";
    		break;
    	} 
    }

    You will of course need to manually enter the VAT numbers you are trying to display using the code above, where you see “GB123” & “France123”.

    Here is a list of the country codes: https://dev.maxmind.com/geoip/legacy/codes/iso3166/
    You can following the “case” to “break” pattern in order to add more countries. The country codes are what you see as “GB” & “FR” in the code above. ??

    If you haven’t used hooks before, please read this guide: https://docs.wpovernight.com/general/how-to-use-filters/

    • This reply was modified 3 years, 7 months ago by Darren Peyou. Reason: additional instructions
Viewing 1 replies (of 1 total)
  • The topic ‘Additional merchant VAT number’ is closed to new replies.