Magento2: Subtotal Cart Price Rule excludes product tax

Created on 2 Jun 2020  路  23Comments  路  Source: magento/magento2

Preconditions (*)

Magento ver. 2.3.5-p1 - upgraded from 2.3.3 using composer

  1. Product price includes product tax. Product tax is 21%. Shipping table rate is 6 euro.
  2. Create subtotal cart price rule to have free shipping start from 99 euro. Use 0 discount either as fixed value or percentage, tried both configurations
  3. Shipping costs set to 6 euro from table rates

Steps to reproduce (*)

  1. As customer, add a product to the cart of 102 euro
  2. Go to checkout
  3. Look at the shipping costs displayed as part of the cart price
  4. The shipping costs remain on 6 euro
  5. The order total is product price + shipping costs = 102 + 6 euro

Expected result (*)

  1. At checkout, the subtotal cart rule should evaluate the product price including tax, being 102
  2. The subtotal cart rule applies the free shipping and 0 discount
  3. The order total is only product price and has 0 shipping costs: 102 euro

Actual result (*)

  1. At checkout, the subtotal cart rule should evaluate the product price including tax, being 102 euro
  2. The subtotal cart rule does not apply the free shipping and 0 discount
  3. The order total remains at product price and 6 euro shipping costs: 108 euro

  • Severity: S1 _- Affects critical data or functionality and forces users to employ a workaround._
Format is valid done Reported on 2.3.3

All 23 comments

Hi @bamboekeizer. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


Hi @bamboekeizer. Thank you for your request. I'm working on Magento 2.4-develop instance for you

Hi @bamboekeizer, here is your Magento instance.
Admin access: https://i-28472-2-4-develop.instances.magento-community.engineering/admin_a0ab
Login: b3d8be9e Password: fac8c1affc86
Instance will be terminated in up to 3 hours.

We have the same issue on Magento 2.3.5-p1. For a workaround I changed the free shipping amount to the subtotal price - tax.

@magento give me 2.3.5-p1 instance

Hi @bamboekeizer. Thank you for your request. I'm working on Magento 2.3.5-p1 instance for you

Hi @bamboekeizer, here is your Magento instance.
Admin access: https://i-28472-2-3-5-p1.instances.magento-community.engineering/admin_f71f
Login: 24628926 Password: bef83902a39b
Instance will be terminated in up to 3 hours.

Reproduced successfully on 2.3.5-p1

Hi @VigneshVenkatesan154. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Also having this issue. Reproduced on 2.3.5-p1.

Temporary workaround is:
$amount / 1,{$taxrate}. So in NL (21%) with 20$ MOQ:
20/1,21 = 16,53. If you fill this in your good.

Also having this issue in 2.3.5-p1.
Got second problem which is according to this one: we have the issue, that free shipping is also calculated without tax #13392
we did not have this in 2.3.4-p2 and so we investigated changes:

found this:
vendor\magento\module-tax\Model\Sales\Total\Quote\CommonTaxCollector.php Line 596FF
$address = $shippingAssignment->getShipping()->getAddress();
$address->setBaseSubtotalTotalInclTax($baseSubtotalInclTax);
$address->setSubtotal($total->getSubtotal());
$address->setBaseSubtotal($total->getBaseSubtotal());

removed
$address->setSubtotal($total->getSubtotal());
$address->setBaseSubtotal($total->getBaseSubtotal());
for test and both issues where fixed?!

@magento give me 2.3.5-p2 instance

Hi @k4emic. Thank you for your request. I'm working on Magento 2.3.5-p2 instance for you

Hi @k4emic, here is your Magento instance.
Admin access: https://i-28472-2-3-5-p2.instances.magento-community.engineering/admin_3d2c
Login: fee6df65 Password: 940632d1e907
Instance will be terminated in up to 3 hours.

@magento give me 2.3.5-p1 instance

Hi @k4emic. Thank you for your request. I'm working on Magento 2.3.5-p1 instance for you

Hi @k4emic, here is your Magento instance.
Admin access: https://i-28472-2-3-5-p1.instances.magento-community.engineering/admin_29e6
Login: d501ef65 Password: 9518be51ad2f
Instance will be terminated in up to 3 hours.

Also reproducible on 2.3.5-p2.

We worked around this by introducing a new condition option

--- Model/Rule/Condition/Address.php    2020-09-03 12:01:26.000000000 +0200
+++ Model/Rule/Condition/Address.php    2020-09-03 12:53:46.000000000 +0200
@@ -62,7 +62,8 @@
     {
         $attributes = [
             'base_subtotal_with_discount' => __('Subtotal (Excl. Tax)'),
-            'base_subtotal' => __('Subtotal'),
+            'base_subtotal' => __('Subtotal (Avoid this one: Known to be unreliable for most tax settings)'),
+            'base_subtotal_total_incl_tax' => __('Subtotal (Incl. Tax)'),
             'total_qty' => __('Total Items Quantity'),
             'weight' => __('Total Weight'),
             'payment_method' => __('Payment Method'),

Bumping this ticket as this is quite a critical feature.

The descriptive labels on the address attributes are just plain wrong. The first option was introduced in https://github.com/magento/magento2/pull/21288 but this clearly was a mistake and never properly tested.

The suggestion of @k4emic is going towards the right direction with adding the correct option but the labels are still not very descriptive for the excluding tax options.

I also have the same problem on 2.3.5-p2.
We are using at least two tax clases. So for us changing the values in the table rate CSV is no option for us.
@k4emic can you please tell me what I have to do to get your work arround running in my system? I changed vendor/magento/module-sales-rule/Model/Rule/Condition/Address.php as you described, but where can i find this new condition to choose?

thank you!

I believe I am seeing the same problem.
Found inconsistency here vendor/magento/module-quote/Model/Quote/Address.php:1031

$request->setPackageValue($item ? $item->getBaseRowTotal() : $this->getBaseSubtotal());

$this->getBaseSubtotal() should be $this->getBaseTotal() _or_

$item-getBaseRowTotal should be $item->getBaseSubtotal()

This persists in 2.3.6.

Was this page helpful?
0 / 5 - 0 ratings