Support » Plugin: WooCommerce PDF Invoices & Packing Slips » Different template per country ?

  • Hey

    Thank you for a great and helpful plugin.

    Is it possible to have a different template per country? I am wanting to show “tax invoice” information for those users in our home country A (who pay tax) and a “order receipt” (without tax info) for those who are not?

    I guess I could simply show custom text as mentioned in this post – does this technique still work?

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Support kluver

    (@kluver)

    Hi @iamhere,

    You can add a custom text based on the customer’s billing country with a code snippet. The following code snippet adds a custom text based on the billing country after the order details on your invoice:

    add_action ( 'wpo_wcpdf_after_order_details', 'wpo_wcpdf_add_text_to_invoice_based_on_billing_country', 10, 2 );
    function wpo_wcpdf_add_text_to_invoice_based_on_billing_country( $template_type, $order ) {
    	if ( $template_type == 'invoice' ) {
    		//Add your custom texts below...
    		$custom_text_a = 'Your custom text goes here...';
    		$custom_text_b = 'Your other custom text goes here...';
    
    		if ( $order->get_billing_country() == 'AT' ) {
    			printf( '<p class="custom-text">%s</p>', $custom_text_a );
    		} else {
    			printf( '<p class="custom-text">%s</p>', $custom_text_b );
    		}
    	}
    }

    You’ll have to change the custom texts and currently the snippet checks if the billing country is Austria (AT).

    This snippet should be placed in the functions.php of your child theme. If you haven’t worked with code snippets or functions.php before please read this: How to use filters

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.