• Resolved mschouten

    (@mschouten)


    Hello there! I liked the plugin very much!
    Also really nice that it is compatible with the Woocommerce EU VAT Assistant.

    I just have one minor question, because one thing i can get to work;
    In the Netherlands, we have to display a certain text on the invoice between businesses from another Eu country (our government demands it).

    I CAN display this text on my custom invoice template, i have based this on the Vat number:
    <?php $wpo_wcpdf->custom_field('vat_number', 'tabel II, onderdeel a, post 6, Wet OB') ?>
    So it always displays when Vat number is filled in, that is great!

    Only now comes the trick, it doesn’t need to show on the base country of the shop, in this case the Netherlands. SO i had this, before the custom vat_number field:

    <?php if ( WC()->countries->countries[ $order->shipping_country ] != 'NL') : ?>
    <?php $wpo_wcpdf->custom_field('vat_number', 'tabel II, onderdeel a, post 6, Wet OB') ?>
    <?php endif; ?>

    But it doesn’t effect the display, can you help me out?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I was looking for the same thing, my work around at the moment is to use output buffering:

    <?php 
    		ob_start();
    		$wpo_wcpdf->custom_field('_wwpp_order_type');
    		$order_type = ob_get_clean();
    		if($order_type == 'wholesale'){
    		echo "I'm a wholseale order";	
    		}
    		?>

    I’ll follow this if there is already an official method for this. I couldn’t find anything in the documentation about doing this.

    Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    The problem with your first code is twofold: first of all, WC()->countries actually converts the country code to the country name, and the $order object is not available directly but via $this->order.

    In code (using billing_country instead of shipping_country):

    
    <?php if ( $this->order->billing_country != 'NL') : ?>
    <?php $wpo_wcpdf->custom_field('vat_number', 'tabel II, onderdeel a, post 6, Wet OB') ?>
    <?php endif; ?>
    

    @curlypinky
    if you want to check if a custom field exists, you can either use $wpo_wcpdf->get_custom_field() instead of $wpo_wcpdf->custom_field(), or do this directly with WordPress/WooCommerce functions:

    
    // both of these calls do the same thing
    $order_type = $this->order->wwpp_order_type;
    $order_type = get_post_meta($this->order->id, '_wwpp_order_type',true );
    if($order_type == 'wholesale'){
        echo "I'm a wholseale order";   
    }
    

    Hope that helps!
    Ewout

    Thread Starter mschouten

    (@mschouten)

    Ewout, thanks!! that did the trick:)

    Thank you very much Ewout!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom text display on invoice, based on Vat number by Country’ is closed to new replies.