I have a webshop where you can get free shipping when the minimum total order price is €150. Product prices are set up so they include VAT (21%). VAT is removed when orders are shipped outside the Netherlands. In most scenarios shipping cost calculation is not a problem but there is one VAT-related specific scenario where it is not working.

Let's begin with the scenario that works as expected:

1) User buys product(s) which include VAT and the total order amount is €151. Shipping address is inside EU so he is correctly eligible for free shipping.

Now lets go to the scenario where it does not work:

2) User buys the same product(s) as above and the total order amount is again €151. User is again eligible for free shipping but this time shipping is outside the Netherlands. That means that VAT is being excluded and therefore the final amount that user has to pay is below €150 and therefore he should pay for the shipping. But this is not happening.

It seems that system reads the 'total order price' as the total amount of the order before the tax reduction is applied. Therefore, according to the system user is eligible for free shipping. Though this is not correct.

My question is: Is there any way to make system look at the "final" total amount so the shipping calculation is correct?

The current rule for the total in Commerce 1 is in craft/plugins/commerce/models/Commerce_ShippingRuleModel.php starting at line 214:

if ($this->minTotal && $this->minTotal > $order->itemTotal)
{
    return false;
}
if ($this->maxTotal && $this->maxTotal <= $order->itemTotal)
{
    return false;
}

Try changing it to use totalPrice and see if that resolves the issue for you:

if ($this->minTotal && $this->minTotal > $order->totalPrice)
{
    return false;
}
if ($this->maxTotal && $this->maxTotal <= $order->totalPrice)
{
    return false;
}

If we were to go ahead and change it in core, it would be a breaking change for other users. The only way around that is to make a new setting.

If it resolves the issue for you, I will look into making the new setting.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.