2

I want to create a rule that gives people a discount of 10% if the subtotal of the cart is over $100.

I have this rule working but with one problem, to check weather the cart is over $100 it is using the subtotal without tax were I want it to use the subtotal with tax.

The condition I am using is pictured below.

enter image description here

I have looked into changing Configuration -> Sales -> Tax settings but most of these settings are already set how I need them for the rest of the site. There are also some products with and without tax so I cannot try and cheat my way by using a lower number.

  • Take a look at my answer – LucScu Jun 5 '18 at 6:50
1

Same issue with magento 2.2.2.

When you create a cart rule and you select Subtotal as cart attribute condition you are choosing the html option value value="Magento\SalesRule\Model\Rule\Condition\Address|base_subtotal".

It means that the cart rule will use the quote_address.base_subtotal column to validate the coupon's condition.

If your catalog has the Catalog Prices option (Stores->Configuration->Sales->Tax->Calculation Settings) setted to Excluding Tax the quote_address.base_subtotal will contain subtotal WITHOUT tax.

Now, digging in the magento core i found that the cart rule condition is validated in vendor/magento/module-rule/Model/Condition/AbstractCondition.php with validate() method.

To fix the issue, i changed the code in

...
$attr = $this->getAttribute();
if ($attr == "base_subtotal") $attr = "base_subtotal_total_incl_tax";

$attributeValue = $model->getData($attr);

return $this->validateAttribute($attributeValue);
...

so, quote_address.base_subtotal_total_incl_tax will be used instead of quote_address.base_subtotal.

PS1: i also tried a lot on the web to find a solution and i did not find anything

PS2: i changed and suggested how to fix the issue directly in the core file, but it is a bad pratice, take your precautions :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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