Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Subtotal (Excl. Tax)" condition for Cart rule is not working for FREE Shipping #36760

Closed
3 tasks
MagePsycho opened this issue Jan 20, 2023 · 24 comments
Closed
3 tasks
Assignees
Labels
Area: Cart & Checkout Component: Checkout Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.3-p2 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@MagePsycho
Copy link
Contributor

MagePsycho commented Jan 20, 2023

Preconditions and environment

  • Magento version 2.4.3-p2
  • Enable Tablerate shipping

Steps to reproduce

Backend

  1. Create a cart rule with following
  • {{{}Conditions{}}}: Subtotal (Excl. Tax) is equals or greater than 100
  • {{{}Actions{}}}: Free Shipping = For matching items only
  1. Create another cart rule with coupon XYZ to give a Fixed amount discount for whole cart of 10

Storefront

  1. Add items to the cart to make a subtotal of 105
  2. Apply the coupon XYZ to get 10$ OFF

Expected result

The shipping fee should not be 0 (i.e. FREE shipping cart rule should not be applied)

Actual result

The shipping fee is showing 0 (i.e. FREE shipping cart rule is applied)

Additional information

!https://user-images.githubusercontent.com/1205071/213676297-f3145d58-e179-47fb-aebc-19d5edb4e47a.png|width=593,height=348!

Quick n Dirty Solution

Step debugging showed that the value provided by the $address->getData('base*subtotal_with*discount') is not correct:
!https://user-images.githubusercontent.com/1205071/213677260-afb0ac81-6fd1-450a-a945-3212f479f63c.png|width=509,height=152!

So ended up tweaking as below:

\Magento\OfflineShipping\Model\SalesRule\Calculator::processFreeShipping()
``{{
public function processFreeShipping(\Magento\Quote\Model\Quote\Item\AbstractItem $item)
{
$address = $item->getAddress();

$item->setFreeShipping(false);

foreach ($this->_getRules($address) as $rule) {

/* Quick Fix - Start /
$address->setBaseSubtotalWithDiscount($address->getBaseSubtotal() + $address->getBaseDiscountAmount());
/
Quick Fix - End */

/* @var $rule \Magento\SalesRule\Model\Rule */
if (!$this->validatorUtility->canProcessRule($rule, $address))

{ continue; }

}}``

Release note

No response

Triage and priority

  • < ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ > Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Jan 20, 2023

Hi @MagePsycho. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

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

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

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

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-assistant
Copy link

m2-assistant bot commented Jan 20, 2023

Hi @engcom-Bravo. 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: 👇

  • 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.

@engcom-Bravo engcom-Bravo added the Reported on 2.4.3-p2 Indicates original Magento version for the Issue report. label Jan 20, 2023
@MagePsycho MagePsycho changed the title "Subtotal (Excl. Tax)" for Cart rule is not working for FREE Shipping "Subtotal (Excl. Tax)" condition for Cart rule is not working for FREE Shipping Jan 20, 2023
@engcom-Bravo
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@engcom-Bravo
Copy link
Contributor

Hi @MagePsycho,

Thank you for reporting and collaboration.
Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

1.Create a cart rule with following
a.Conditions: Subtotal (Excl. Tax) is equals or greater than 100
b.Actions: Free Shipping = For matching items only
2.Create another cart rule with coupon XYZ to give a Fixed amount discount for whole cart of 10

Screenshot 2023-01-25 at 3 08 23 PM

We are giving as a condition subtotal should be equals or greater than 100.we added a product into cart greater 100 so in that case free shipping is applying.

Kindly let us know if we missed anything.

Thanks.

@engcom-Bravo engcom-Bravo added the Issue: needs update Additional information is require, waiting for response label Jan 25, 2023
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Jan 25, 2023
@MagePsycho
Copy link
Contributor Author

Hi @MagePsycho,

Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

1.Create a cart rule with following a.Conditions: Subtotal (Excl. Tax) is equals or greater than 100 b.Actions: Free Shipping = For matching items only 2.Create another cart rule with coupon XYZ to give a Fixed amount discount for whole cart of 10

Screenshot 2023-01-25 at 3 08 23 PM

We are giving as a condition subtotal should be equals or greater than 100.we added a product into cart greater 100 so in that case free shipping is applying.

Kindly let us know if we missed anything.

Thanks.

Please apply the coupon and check if still the FREE shipping is getting applied?

@engcom-Bravo
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@engcom-Bravo
Copy link
Contributor

engcom-Bravo commented Jan 27, 2023

Hi @MagePsycho,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

1.Create a cart rule with following
a.Conditions: Subtotal (Excl. Tax) is equals or greater than 100
b.Actions: Free Shipping = For matching items only
2.Create another cart rule with coupon XYZ to give a Fixed amount discount for whole cart of 10

Screenshot 2023-01-27 at 3 17 53 PM

Screenshot 2023-01-27 at 3 14 11 PM

As per first cart price subtotal is greater than 100 hence in that case we are getting free shipping.

We are not able to apply coupon(2 cart price rule) .Please let us know if you are facing issue to apply coupon.

Shopping-Cart (2)

Thanks.

@MagePsycho
Copy link
Contributor Author

MagePsycho commented Jan 27, 2023

Hi @MagePsycho,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

1.Create a cart rule with following a.Conditions: Subtotal (Excl. Tax) is equals or greater than 100 b.Actions: Free Shipping = For matching items only 2.Create another cart rule with coupon XYZ to give a Fixed amount discount for whole cart of 10

Screenshot 2023-01-27 at 3 17 53 PM Screenshot 2023-01-27 at 3 14 11 PM

As per first cart price subtotal is greater than 100 hence in that case we are getting free shipping.

We are not able to apply coupon(2 cart price rule) .Please let us know if you are facing issue to apply coupon.

Shopping-Cart (2)

Thanks.

Please make sure the coupon code (discount) is applied (create a cart rule with such coupon code first).
If a discount of 10$ is applied, still the Shipping FEE is 0 <-- this is the issue

@engcom-Bravo
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@engcom-Bravo
Copy link
Contributor

Hi @MagePsycho,

Thanks for your update.

sahch-Promotions-Marketing-Magento-Admin

rgss-Promotions-Marketing-Magento-Admin

Shopping-Cart (3)

We have created 2 cart price rules.1 for condition and 1 for coupon code.

We are not able to apply coupon code for a product please let us know you are facing issue to apply coupon.

Thanks.

@MagePsycho
Copy link
Contributor Author

Hi @MagePsycho,

Thanks for your update.

sahch-Promotions-Marketing-Magento-Admin

rgss-Promotions-Marketing-Magento-Admin

Shopping-Cart (3)

We have created 2 cart price rules.1 for condition and 1 for coupon code.

We are not able to apply coupon code for a product please let us know you are facing issue to apply coupon.

Thanks.

Please make the coupon work (Maybe you need to make Discard Subsequent Rules = No in both cart rules).

@engcom-Bravo
Copy link
Contributor

Hi @MagePsycho,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Created a cart rule with following

Conditions: Subtotal (Excl. Tax) is equals or greater than 100
Actions: Free Shipping = For matching items only

Add-Promotions-Marketing-Magento-Admin (1)

Created another cart rule with coupon XYZ to give a Fixed amount discount for whole cart of 10

Test-Promotions-Marketing-Magento-Admin (1)

Storefront

1.Add items to the cart to make a subtotal of 105
2.Apply the coupon XYZ to get 10$ OFF

As per 1 cart price rule we added a product with a price of 105, hence we are getting free shipping.

Shopping-Cart (4)

Here we are applying coupon code with a discount of 10 hence the subtotal is reduced to 95 so in that case free shipping should not be applied as per 1 cart price rule. Free shipping should be applied when subtotal is 105.

Shopping-Cart (5)

Hence confirming the issue.

Thanks.

@engcom-Bravo engcom-Bravo removed the Issue: needs update Additional information is require, waiting for response label Feb 6, 2023
@m2-community-project m2-community-project bot moved this from Needs Update to Ready for Confirmation in Issue Confirmation and Triage Board Feb 6, 2023
@Vasudev-22
Copy link
Contributor

@magento I am working on this

@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Feb 8, 2023
@Vasudev-22
Copy link
Contributor

Hi @engcom-Bravo , @MagePsycho ,

In Adobe Magento, we can add multiple cart rules at a time without coupon code

So, Here the scenario is

Rule 1 :- Without COUPON
a. Subtotal will be equal or greater than 100 .
b. Free Shipping for item matching only.

Rule 2 :- With COUPON, Apply discount for the whole cart amount is 10%.

In Cart,
we have product subtotal above 100,

Scenario 1:- let assume as 105

so Rule 1 will apply without coupon , so Table Rate shipping come to zero 
next Rule 2 with coupon can apply along with this Rule 1 , because  we made Discard Subsequent Rules = No in both cart rules.

Scenario 2:- let assume as 90

    Rule 1 will not apply without coupon , because  its not upto the condition, so we have table rate shipping value.
next Rule 2 with coupon can apply .

Scenario 1 is expected , Please let me know if i was understanding in different way.
So, this is not a valid issue.

@MagePsycho
Copy link
Contributor Author

MagePsycho commented Feb 8, 2023

Hi @engcom-Bravo , @MagePsycho ,

In Adobe Magento, we can add multiple cart rules at a time without coupon code

So, Here the scenario is

Rule 1 :- Without COUPON a. Subtotal will be equal or greater than 100 . b. Free Shipping for item matching only.

Rule 2 :- With COUPON, Apply discount for the whole cart amount is 10%.

In Cart, we have product subtotal above 100,

Scenario 1:- let assume as 105

so Rule 1 will apply without coupon , so Table Rate shipping come to zero 
next Rule 2 with coupon can apply along with this Rule 1 , because  we made Discard Subsequent Rules = No in both cart rules.

Scenario 2:- let assume as 90

    Rule 1 will not apply without coupon , because  its not upto the condition, so we have table rate shipping value.
next Rule 2 with coupon can apply .

Scenario 1 is expected , Please let me know if i was understanding in different way. So, this is not a valid issue.

The issue I am raising is:
"Subtotal (Excl. Tax)" condition doesn't care about the discount, ideally it should.

So if you configure the FREE shipping cart rule with Subtotal (Excl. Tax) >= 100 (for example).
And in the storefront, you apply a discount of 10 (for example, via coupon code or whatever) for a cart with a subtotal of 105 (for example). In this case, Subtotal (Excl. Tax) becomes 105 - 10 = 95, and FREE should not get applied.

But Magento is still giving FREE shipping (but it shouldn't).

Note that Subtotal (Excl. Tax) internally means base_subtotal_with_discount (The label is kinda misleading :))

@engcom-Hotel
Copy link
Contributor

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-7886 by the internal team
Related commits: https://github.com/magento/magento2/search?q=AC-7886&type=commits

Based on the Jira ticket, the target version is 2.4.7-beta1.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Cart & Checkout Component: Checkout Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: done Reported on 2.4.3-p2 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Development

Successfully merging a pull request may close this issue.

5 participants