1
votes

I have prices showing on my woocommerce product pages that show exc. VAT and inc. VAT which is fine when tax in selected country is 20% however when I select a country that has 0% tax my prices show the same amount for both inc and exc. ie 15.00 exc vat and 15.00 inc vat. How can I hide the including vat amount when the country selected has 0% tax rate?

I have updated my price.php file to the latest woocommerce version but the pricing remains the same.

<?php if ( $price_html = $product->get_price_html() ) : ?>

    <span class="price-excvat"><?php echo wc_price( wc_get_price_excluding_tax( $product ) ); ?> Exc. VAT</span><br />

    <span class="price-incvat"><?php echo wc_price( wc_get_price_including_tax( $product ) ); ?> Inc. VAT</span>

<?php endif; ?>
1

1 Answers

0
votes

Try the following to display just the price Inc. VAT for 0 taxes (updated):

<?php if ( $price_html = $product->get_price_html() ) : ?>

<?php 
    $price_excl_tax = wc_get_price_excluding_tax( $product ); 
    $price_incl_tax = wc_get_price_including_tax( $product ); 

    if ( $price_excl_tax !== $price_incl_tax ) : ?>

    <span class="price-cvat"><?php echo wc_price( wc_get_price_excluding_tax( $product ) ); ?> Exc. VAT</span><br />

    <span class="price-incvat"><?php echo wc_price( wc_get_price_including_tax( $product ) ); ?> Inc. VAT</span>

    <?php else : ?>

    <span class="price-zerovat"><?php echo wc_price( wc_get_price_including_tax( $product ) ); ?></span>

    <?php endif; ?>

    <span class="price-incvat"><?php echo wc_price( wc_get_price_including_tax( $product ) ); ?> Inc. VAT</span>

<?php endif; ?>

It should work.