Woocommerce: Same gross price for different tax rates


We have a pretty tricky problem: We run a german Woocommerce shop. All prices are including 19% VAT. For Austria we have to calculate 20%, but the prices including VAT should be the same. This can be easily done using the woocommerce_adjust_non_base_location_prices filter.

Now comes the tricky part: Since Switzerland is not part of the EU, products are sold excluding VAT. If we set the VAT settings for Switzerland to 0%, it’s not working anymore with the filter added. Example:

Product costs 100 EUR including 19% VAT.

German buyers pay 100 EUR including 16 EUR VAT
Austrian buyers pay 100 EUR including 17 EUR VAT
Buyers from Switzerland SHOULD pay 84 EUR (100 EUR – 16 EUR VAT), but the system calculates 100 EUR.

A quick and dirty workaround would be to exclude the filter for buyers from Switzerland. I tried:

add_action( 'woocommerce_checkout_update_order_review', 'vd_adjust_ch_prices', 0, 1 );

public function vd_adjust_ch_prices( $post_data ) {
   if ( isset( $_POST['country'] ) && ! in_array( $_POST['country'], WC()->countries->get_european_union_countries() ) || ( ! isset( $_POST['country'] ) && ! in_array( WC()->checkout()->get_value('billing_country'), WC()->countries->get_european_union_countries() ) ) ) {
    add_filter( 'woocommerce_product_is_taxable', '__return_false', 20 );

The snippet does not work, and don’t know why. Any ideas?

user2516117 2 years 2019-12-27T12:05:08-05:00 0 Answers 66 views 0

Leave an answer