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

Magento 2.4.5 - Free shipping not applied with cart price rule #35967

Closed
1 of 5 tasks
pixel-paul opened this issue Aug 17, 2022 · 36 comments
Closed
1 of 5 tasks

Magento 2.4.5 - Free shipping not applied with cart price rule #35967

pixel-paul opened this issue Aug 17, 2022 · 36 comments
Assignees
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.5 Indicates original Magento version for the Issue report.

Comments

@pixel-paul
Copy link

Preconditions and environment

  • Magento 2.4.5
  • PHP 8.1

This was working in 2.4.4

Steps to reproduce

Create a cart price rule for free shipping:

Screenshot 2022-08-17 at 14-34-46 Free Shipping _ Promotions _ Marketing _ Magento Admin

Expected result

Order should have shipping set to £0

Actual result

Order does not have shipping set to £0.00:

Screenshot 2022-08-17 at 14-37-18 Shopping Cart

Additional information

No response

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 Aug 17, 2022

Hi @pixel-paul. 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 Aug 17, 2022

Hi @engcom-Delta. 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.5 Indicates original Magento version for the Issue report. label Aug 17, 2022
@engcom-Delta
Copy link
Contributor

engcom-Delta commented Aug 17, 2022

Hi @pixel-paul ,
Thank you for raising an issue and We tried to reproduce the issue on magento 2.4.5. issue is reproducible but we are confused on free shipping and conditions of shared screenshots. Hence request to review the provided steps .

Followed steps:

  1. Create cart price rule with free shipping in admin portal

Screenshot 2022-08-17 at 8 08 29 PM

Screenshot 2022-08-17 at 8 09 12 PM

Screenshot 2022-08-17 at 8 11 45 PM

  1. Go to frontend and add an items to cart
  2. Cart sub total should be equal or greater than 75
  3. Go to checkout page
  4. Please review shipping cost

Screenshot 2022-08-17 at 8 07 17 PM

Screenshot 2022-08-17 at 8 40 30 PM

Thanks

@engcom-Delta engcom-Delta added Issue: needs update Additional information is require, waiting for response and removed Issue: ready for confirmation labels Aug 17, 2022
@pixel-paul
Copy link
Author

Hi @engcom-Delta,

Thanks for looking into this.

Am I missing something here, but in your example the shipping is not discounted?

Thanks,

Paul

@engcom-Delta
Copy link
Contributor

Hi @pixel-paul ,
Thanks for quick response, We should follow the below document for free shipping , it works fine
https://docs.magento.com/user-guide/shipping/shipping-free.html.

I have cross checked i could see free shipping got applied.

Screenshot 2022-08-18 at 3 24 30 PM

Screenshot 2022-08-18 at 3 24 30 PM

Screenshot 2022-08-18 at 3 21 11 PM

Screenshot 2022-08-18 at 4 17 51 PM

@danhort
Copy link

danhort commented Aug 18, 2022

@engcom-Delta I am encountering the same issue described above with free shipping applied by cart price rule.
In your previous comment you are talking about free shipping applied by shipping method. These are two different ways to apply free shipping.

@danhort
Copy link

danhort commented Aug 18, 2022

Here is a quick fix for this bug applied to magento/module-quote reverting some code from the following commit bd14944.

index 64725d8..aef9fb0 100644
--- a/Model/Quote/Address/Total/Shipping.php
+++ b/Model/Quote/Address/Total/Shipping.php
@@ -73,7 +73,7 @@ class Shipping extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
         $address->setFreeMethodWeight($data['freeMethodWeight']);
 
         $isFreeShipping = $this->freeShipping->isFreeShipping($quote, $shippingAssignment->getItems());
-        $address->setFreeShipping((int)$isFreeShipping);
+        $address->setFreeShipping($isFreeShipping);
         // recalculate weights
         $data = $this->getAssignmentWeightData($address, $shippingAssignment->getItems());
         $address->setItemQty($data['addressQty']);
diff --git a/Test/Unit/Model/Quote/Address/Total/ShippingTest.php b/Test/Unit/Model/Quote/Address/Total/ShippingTest.php
index 495a19c..54c2ac5 100644
--- a/Test/Unit/Model/Quote/Address/Total/ShippingTest.php
+++ b/Test/Unit/Model/Quote/Address/Total/ShippingTest.php
@@ -218,7 +218,7 @@ class ShippingTest extends TestCase
         $this->address
             ->expects($this->once())
             ->method('setFreeShipping')
-            ->with((int)$isFreeShipping);
+            ->with($isFreeShipping);
         $this->total->expects($this->atLeastOnce())
             ->method('setTotalAmount');
         $this->total->expects($this->atLeastOnce())```

@pixel-paul
Copy link
Author

Hi @engcom-Delta - you have provided two different methods to add free shipping. The method I am using, as confirmed by @danhort is this method:

https://docs.magento.com/user-guide/marketing/price-rules-cart-free-shipping.html

It looks like you have used this method in your first example. Please retest and confirm this as it looks very much like a bug.

@pixel-paul
Copy link
Author

Here is a quick fix for this bug applied to magento/module-quote reverting some code from the following commit [bd14944].

That is great, thank you @danhort - I can confirm that this corrects the issue.

@engcom-Delta - can you retest please using the cart price rule method of providing free shipping? This appears to be a bug.

@engcom-Delta
Copy link
Contributor

Hi @pixel-paul ,
Thank you for more inputs, followed the link https://docs.magento.com/user-guide/marketing/price-rules-cart-free-shipping.html and tried to replicate it but issue is not reproducible on magento 2.4.5 instance . Free shipping got applied in two scenarios .

Here is the videos for reference.

  1. https://www.loom.com/share/de7af3323e9f41518f736c3bb0d6123f
  2. https://www.loom.com/share/fd1d4faf8d2a494d8fcc2c5667feef92

Regards,

@pixel-paul
Copy link
Author

Hi @engcom-Delta - my guess is that the issue is with upgrade from 2.4.4 to 2.4.5 - might be worth checking that the value for $isFreeShipping is actually an int in the upgrade from 2.4.4 to 2.4.5.

@engcom-Delta
Copy link
Contributor

engcom-Delta commented Sep 7, 2022

Hi @pixel-paul

We have tried to reproduce this issue in magento 2.4.5 ,2.4-develop and upgrade Magento 2.4.4 to 2.4.5 but the issue is not reproducible .

Steps are followed to reproduce the issue
(we have followed the steps which are mentioned in this link https://docs.magento.com/user-guide/marketing/price-rules-cart-free-shipping.html )

1.Upgrade magento 2.4.4 to magento 2.4.5

2.Enabled free shipping
Screenshot 2022-09-07 at 12 29 51 PM

3.Create a cart price rule for free shipping
Screenshot 2022-09-07 at 12 42 41 PM

Screenshot 2022-09-07 at 12 43 24 PM

4.Proceed to checkout and checked the free shipping applied
Screenshot 2022-09-07 at 1 09 17 PM

Screenshot 2022-09-07 at 1 10 54 PM

Screenshot 2022-09-07 at 1 11 47 PM

Here, the free shipping is applied

  1. We have checked the $isFreeShipping is an int in the below file
    Model/Quote/Address/Total/Shipping.php

Screenshot 2022-09-08 at 12 10 31 PM

Please let us know if we are missing any steps here.
Thanks

@engcom-Delta
Copy link
Contributor

Hi @pixel-paul ,

We have noticed that, this issue has not been updated for a period of 14 Days.Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks.

@engcom-Delta engcom-Delta removed the Issue: needs update Additional information is require, waiting for response label Sep 22, 2022
@MartinKonVis
Copy link

MartinKonVis commented Oct 17, 2022

We got a similar problem. The same setings like above.
Shopping cart rules and table rates seems not longer to work?

We had not used the free shipping method. We used shopping cart rules only to reduce the shipping cost of table rates too "free"/0€. Before the update the table rates shipping methods showed corretcly"0€" for shipping (when conditions are met).

After the update the free shipping in combination with shipping cart rules does not work anymore. It shows wrong table rates values. Instead of 0€ or the correct value it showed values of a lower table rate level.

settings:
Magento 2.4.5
PHP 8.1

Conditions of shopping cart rules
01conditions

Actions
01 actions

Additional info regarding table rates which are used
Country,Region/State,"Zip/Postal Code","Weight (and above)","Shipping Price"
DEU,,,0.0000,2.9500
DEU,,,1.0000,5.9500

"DEU" is for Germany => please use Germany for testing in checkout

setting of table rates => weight vs destination
table-rates

Results before the update
-> the cart rules were used to set shipping of shipping method table rates to 0€ based on subtotal and if country matches
-> if the subtotal was higher than 69€ + country was germany => 0€ shipping tablerates was shown
-> if the subtotal was lower than 69€ + country was germany (or other) => regular shipping costs based on tablerates were shown

-> we did not use shipping method "free shipping". We had it not activated and it was working like descriebed above.

Results after the update
->(correct) we activated "free shipping" shippingmethod and set min amount to 200 (higher as the shipping cart rules) like it said in the documentation (https://experienceleague.adobe.com/docs/commerce-admin/marketing/promotions/cart-rules/price-rules-cart-free-shipping.html)
When the shopping cart rule got meet it got shown correctly based on the shopping cart rule. Shipping method "free shipping" showed up which is correct.

-> (wrong) the "table rate" shipping shows now wrong shipping rate (lowest) if the conditions are met. This makes no sense from our point of view? It somehow reduced the weight in the cart to meet the lower rule?
Correct was (before the update) it showed 0€ for the table rates because free shipping was met.

if rule is not active => correct table rates are shown based on weight in cart
rule-inactive

if the rule is triggered / conditons are met => wrong table rates are shown
rule-active

Nothing has changed in the cart. Before the update it showed "0.00" because of free shipping
-> first line is "free shipping" method which seems to be ok?
-> second line is table rates shipping method which shows now wrong shipping costs?

Now it shows a wrong table rate. Correct would be this line DEU,,,1.0000,5.9500 => 5,95 €
But somehow it is now "DEU,,,0.0000,2.9500" => 2,95 €

Correct would be from our point of view (like it was before the update)
-> no "free shipping" shipping method is needed to be activated?
-> table rates shipping costs are reduced to 0€ if the shopping cart rules are meet

@nocturnalfrog
Copy link

@engcom-Delta Please reopen this issue.
The "Free Shipping" delivery method did not use to be required and is a different method all together.
The goal of a cart rule is to lower the price of specific shipping methods.

Forcing people to select a different shipping method is not acceptable.

The customer should still be able to pick the delivery method they want (ex: Parcel Depot, Weekend Delivery, etc.)

@engcom-Hotel
Copy link
Contributor

Hello @nocturnalfrog @MartinKonVis,

Thanks for your comment!

We are reopening this issue for further process.

Thanks

@tramov
Copy link

tramov commented Feb 7, 2023

Adding a +1 as changing this cast by removing (int) has fixed the free shopping cart rule that broke after the 2.4.5-p1 (from 2.3.5) upgrade.

@m2-assistant
Copy link

m2-assistant bot commented Feb 28, 2023

Hi @engcom-Dash. 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).
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    1. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    1. 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!

@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@engcom-Dash
Copy link
Contributor

Hi @pixel-paul ,

Thanks for your information and collaboration,

We are verified the issue again in 2.4-develop branch as well as 2.4.5-p1 instance and the issue is not reproducible.We are getting the free shipping method.

Preconditions:
Magento Version 2.4-develop and 2.4.5-p1
PHP version :8.1

Steps to reproduce:
Steps are followed to reproduce the issue
(we have followed the steps which are mentioned in this link https://docs.magento.com/user-guide/marketing/price-rules-cart-free-shipping.html )

1.Upgrade magento 2.4.4 to magento 2.4.5

2.Enabled free shipping

Screenshots:
cpr1
cpr2
cpr3
cpr4
cpr5
cpr6

Thanks.

@engcom-Dash engcom-Dash added the Issue: needs update Additional information is require, waiting for response label Feb 28, 2023
@nocturnalfrog
Copy link

@engcom-Dash
The problem is that this Cart Price Rule used to cause "Flat Rate" to cost €0.00 not add an extra shipping option!

What if we always offered Free Shipping for slow delivery and used "Flat Rate" for next day delivery?
What if we integrate with a third party shipping partner?

The "Free Shipping" delivery method did not use to be required and is a different method all together.
The goal of a cart rule is to lower the price of specific shipping methods.

@engcom-Dash
Copy link
Contributor

Hi @pixel-paul ,

We are closing this issue as there has been no latest update on the same. Kindly reopen / create new issue if you are still facing any issues.
Thank you.

@dtamajon
Copy link

dtamajon commented Apr 2, 2023

Hi,

We are having the same issue with discounts. We cannot use "Free shipping" method because we have more complex options to decide if the shipping is free or not.

Force to use the "Free shipping" method is not a solution for our case.

@vipinroy
Copy link

vipinroy commented May 4, 2023

Here is a quick fix for this bug applied to magento/module-quote reverting some code from the following commit bd14944.

index 64725d8..aef9fb0 100644
--- a/Model/Quote/Address/Total/Shipping.php
+++ b/Model/Quote/Address/Total/Shipping.php
@@ -73,7 +73,7 @@ class Shipping extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
         $address->setFreeMethodWeight($data['freeMethodWeight']);
 
         $isFreeShipping = $this->freeShipping->isFreeShipping($quote, $shippingAssignment->getItems());
-        $address->setFreeShipping((int)$isFreeShipping);
+        $address->setFreeShipping($isFreeShipping);
         // recalculate weights
         $data = $this->getAssignmentWeightData($address, $shippingAssignment->getItems());
         $address->setItemQty($data['addressQty']);
diff --git a/Test/Unit/Model/Quote/Address/Total/ShippingTest.php b/Test/Unit/Model/Quote/Address/Total/ShippingTest.php
index 495a19c..54c2ac5 100644
--- a/Test/Unit/Model/Quote/Address/Total/ShippingTest.php
+++ b/Test/Unit/Model/Quote/Address/Total/ShippingTest.php
@@ -218,7 +218,7 @@ class ShippingTest extends TestCase
         $this->address
             ->expects($this->once())
             ->method('setFreeShipping')
-            ->with((int)$isFreeShipping);
+            ->with($isFreeShipping);
         $this->total->expects($this->atLeastOnce())
             ->method('setTotalAmount');
         $this->total->expects($this->atLeastOnce())```

Can we use this code change? We are struggling with this issue after we upgraded to 2.3.5-p2

@fharms
Copy link

fharms commented May 25, 2023

We had the same issue after upgrading to 2.4.5-p2 the free shipping stopped working. After some debugging I found out that the issue was in one of our 3 party extension handling shipments.

They are expecting type boolean. if ($request->getFreeShipping() === true) {...}, but that will not work because the type containing the information if it is free shipping or not, was specific casted to an int in this commit.
bd14944#diff-857bf9d4a0e8e8b036a3fcf5687e2dbe7f8a4b83ad3ebdabcb0ad66ae0dc7d38

Because of this change it breaks backward compatibility for 3 party extensions, that expected it is a boolean type

@marcomessa
Copy link

marcomessa commented Dec 19, 2023

Thank you guys for these informations. I made a simple module to apply @vipinroy commit in a preference, if you need.
https://github.com/marcomessa/FixMagento2FreeShippingCartRule

Cheers

@pixel-paul
Copy link
Author

I've updated to M246-p5 and I've had to apply this patch by @danhort to get the free shipping to work.

I have table rates enabled and click & collect, I do not use a third party checkout.....very coincidental if this is not a bug in my opinion.

@engcom-Dash
Copy link
Contributor

@magento give me 2.4-develop instance

Copy link

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

Copy link

@engcom-Dash
Copy link
Contributor

Hi @pixel-paul

Thanks for reporting and collaboration.

Verified the issue on magento 2.4 dev instance and the issue is not reproducable.

Steps to reproduce:
Steps are followed to reproduce the issue
(we have followed the steps which are mentioned in this link https://docs.magento.com/user-guide/marketing/price-rules-cart-free-shipping.html )
Created cart price rule for free shipping

We can see the free shipping applied with cart price rule.

Please take a look at the screenshots I've attached. Let us know if we missed anything.

35967_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.5 Indicates original Magento version for the Issue report.
Projects
None yet
Development

No branches or pull requests