WooCommerce INCLUSIVE Shipping Price

In WooCommerce, I can enter a shipping price excluding tax. How can I make the given price including tax?

The settings showing "prices inclusive of taxes" apply only to products.

So, for example, if I enter the delivery settings € 1.00 It shows € 1.21 at checkout (0.21 = tax)

It should be € 1.00 (tax incl. 0.21) (I don't care about the calculation, this is just an example)

Thanks if anyone has a solution or feature for this.

+3


source to share


3 answers


A year after the original question, I just ended up with the same problem and there isn't much to help.

On investigation, this turns out to be a problem with the shipping tax calculation from "class-wc-tax.php", which, as you can see below, refers to shipping without tax.

     /**
     * Calculate the shipping tax using a passed array of rates.
     *
     * @param   float       Price
     * @param   array       Taxation Rate
     * @return  array
     */
    public static function calc_shipping_tax( $price, $rates ) {
        $taxes = self::calc_exclusive_tax( $price, $rates );
        return apply_filters( 'woocommerce_calc_shipping_tax', $taxes, $price, $rates );
    }

      

It turned out that for some reason woo pushed this assumption that shipping is tax exclusive with their downstream tax calculations, so you need to add some filters to your .php functions to fix the situation.

1) First to calculate the inclusive tax

 function yourname_fix_shipping_tax( $taxes, $price, $rates) {

        if(wc_prices_include_tax()){
            return  WC_Tax::calc_inclusive_tax( $price, $rates );
        }

        return $taxes;
    }

    add_filter( 'woocommerce_calc_shipping_tax', 'yourname_fix_shipping_tax',10,3);

      

Be careful that you don't forget 10.3 at the end of add_filter. 10 is the priority, which I left as default. 3 is the number of arguments. You really need this: the filter displays behavioral problems if you don't leave it.

2) The second filter should capture the totals in subsequent calculations.

function yourname_fix_totals( $cart) {

    if(wc_prices_include_tax()){        
        $cart->shipping_total -= $cart->shipping_tax_total;
    }
}
add_filter( 'woocommerce_calculate_totals', 'yourname_fix_totals'); 

      


Details for those who are worried that this is real money and real taxes that we are talking about



The first filter is pretty straightforward - it just recalculates the tax in an inclusive case.

The second filter is a matter of the fact that bringing the tax tax into tax calculations is further aggravated.

Around line 1396 "class-wc-cart.php" we have the following.

// Grand Total - Discounted product prices, discounted tax, shipping cost + tax
    $this->total = max( 0, apply_filters( 'woocommerce_calculated_total', round( $this->cart_contents_total + $this->tax_total + $this->shipping_tax_total + $this->shipping_total + $this->fee_total, $this->dp ), $this ) );

      

What it needs to do is add the shipping tax to the total shipping amount, which we don't want to do, and they hardcoded it into ......

What we're going to do is use the conveniently located "woocommerce_calculate_totals" () filter a few lines above line 1392 to subtract sales tax from the total before everything is added to the top using the second filter above.

// Allow plugins to hook and alter totals before final total is calculated
do_action( 'woocommerce_calculate_totals', $this );

      

In an earlier cut of this post from a few weeks ago, I was worried that this would be a can of worms - and it turns out to be just the way that I can now check things out.

It means huge . Check tax totals and subtotals carefully - this is no longer a risk. Woo made the tax-exclusive shipping speculation and pushed it downstream for their calculations. Unfortunately, you will have to pay taxes to your governments even if there was a mistake in your code.

Remember also that when verifying that old prices will not be affected when going from exclusive to inclusive taxes in woocommerce settings, you might have to use raw test data.

With everything that has been said so far, it looks good to me, but in my scenario, I get around a lot of woo - I am not using any of their front end code, which means I may not have found other places. presumably tax exclusive shipping.

+3


source


In fact, it is located on the "Tax" tab. When you set your tax rates, you also need to check the Shipping box.



enter image description here

+2


source


WooCommerce Germanized offers this option "Erzwinge die Besteuerung für Versandkosten für jede Versandart? Diese Option überschreibt alle abweichenden Einstellungen verschiedener Versandarten und erzwingt die Steuerberechnung".

0


source







All Articles