woocommerce tax and vat

How to add shipping VAT into WooCommerce programmatically

When you use WooCommerce, you can update quite easily shipping costs and taxes for your different shipping costs with the back-office.

The problem is that in the front-office, customers don’t see any details about the tax of your shipping service when they are on the Cart page and Checkout page.

This code is quite simple and you can add it through a new plugin or into your functions.php into your WordPress theme.

This is a code to add :

The goal is simple: We rewrite the shipping part with the hook woocommerce_cart_shipping_method_full_label

As you can see, the $label value is replaced by a new one. The old one is now in a commentary. This new one includes the price with and without taxes. If you want to change how it is displayed, you have to update this line :

$label .= ': ' . wc_price( $method->cost ) . ' ('. wc_price( $method->cost + $method->get_shipping_tax() ) .' incl VAT)';

Your pages will look the same as below:

WooCommerce Cart : Shipping vat and taxes
This is how it is displayed into the cart page
Woocommerce Checkout : Shipping vat and tax
This is how it is displayed into the checkout page

And it’s done, customers can now see VAT details about the shipping!

Still stuck ? You can contact an expert.

Leave a Comment

Your email address will not be published.

You may also like