Closed tiagosampaio closed 2 weeks ago
Hi @tiagosampaio. Thank you for your report. To help us process this issue please make sure that you provided the following information:
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
Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.
:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
Hi @engcom-Oscar. 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).Details
If 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
branchDetails
- 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.
Hi @tiagosampaio ! Thank you for your report. Unfortunately, we are not able to reproduce the issue. May you please update description and add more detailed steps to it, like exact rules configuration? After following steps from the ticket, we got next result:
1 - Create two products with the price of $19 each (SKUs: test-product-one, test-product-two). 2 - Create two Cart Price Rules:
The first rule is applied only to the product test-product-two
(filtered in the actions section)
Applies a fixed discount of $18 on the product's price.
Configuration:
{
"salesrule": [
{
"rule_id" : 5,
"name" : "Test Product Two Discount",
"description" : "",
"from_date" : "2021-05-07",
"to_date" : null,
"uses_per_customer" : 0,
"is_active" : 1,
"conditions_serialized" : "{\"type\":\"Magento\\\\SalesRule\\\\Model\\\\Rule\\\\Condition\\\\Combine\",\"attribute\":null,\"operator\":null,\"value\":true,\"is_value_processed\":null,\"aggregator\":\"all\"}",
"actions_serialized" : "{\"type\":\"Magento\\\\SalesRule\\\\Model\\\\Rule\\\\Condition\\\\Product\\\\Combine\",\"attribute\":null,\"operator\":null,\"value\":\"1\",\"is_value_processed\":null,\"aggregator\":\"all\",\"conditions\":[{\"type\":\"Magento\\\\SalesRule\\\\Model\\\\Rule\\\\Condition\\\\Product\",\"attribute\":\"sku\",\"operator\":\"==\",\"value\":\"test-product-two\",\"is_value_processed\":false,\"attribute_scope\":\"\"}]}",
"stop_rules_processing" : 0,
"is_advanced" : 1,
"product_ids" : null,
"sort_order" : 0,
"simple_action" : "by_fixed",
"discount_amount" : 18.0000,
"discount_qty" : null,
"discount_step" : 0,
"apply_to_shipping" : 0,
"times_used" : 0,
"is_rss" : 1,
"coupon_type" : 1,
"use_auto_generation" : 0,
"uses_per_coupon" : 0,
"simple_free_shipping" : 0,
"row_id" : 5,
"created_in" : 1,
"updated_in" : 2147483647
}
]}
The second one applies a fixed discount of $10 to the whole cart.
{
"salesrule": [
{
"rule_id" : 6,
"name" : "Ten Dollars to Whole Cart",
"description" : "",
"from_date" : "2021-05-07",
"to_date" : null,
"uses_per_customer" : 0,
"is_active" : 1,
"conditions_serialized" : "{\"type\":\"Magento\\\\SalesRule\\\\Model\\\\Rule\\\\Condition\\\\Combine\",\"attribute\":null,\"operator\":null,\"value\":true,\"is_value_processed\":null,\"aggregator\":\"all\"}",
"actions_serialized" : "{\"type\":\"Magento\\\\SalesRule\\\\Model\\\\Rule\\\\Condition\\\\Product\\\\Combine\",\"attribute\":null,\"operator\":null,\"value\":\"1\",\"is_value_processed\":null,\"aggregator\":\"all\"}",
"stop_rules_processing" : 0,
"is_advanced" : 1,
"product_ids" : null,
"sort_order" : 0,
"simple_action" : "cart_fixed",
"discount_amount" : 10.0000,
"discount_qty" : null,
"discount_step" : 0,
"apply_to_shipping" : 0,
"times_used" : 0,
"is_rss" : 1,
"coupon_type" : 2,
"use_auto_generation" : 0,
"uses_per_coupon" : 0,
"simple_free_shipping" : 0,
"row_id" : 6,
"created_in" : 1,
"updated_in" : 2147483647
}
]}
3 - With all set then go to the storefront and add test-product-one
and test-product-two
to the cart.
4 - Go to the shopping cart page and you'll be able to see the discount of -$18.00 already applied because test-product-two
is in the cart.
5 - Apply the coupon code to the cart 6 - Check the discount amount now
The version I used for this testing is Magento Commerce 2.4.2-p1
@engcom-Oscar any update on this?
@tiagosampaio Thank you for your reply, with more detailed steps I was able to reproduce this issue and confirmed it.
The issue is caused by calculation in \Magento\SalesRule\Helper\CartFixedDiscount::getDiscountAmount, there the whole cart price discount is divided between all cart items. So, for the first cart item, total price is 19 - (10 / 2) = $14, and for the second one 19 - (10 / 2) - 18 = -4, that becames $0. Finally, the cart total is 14 + 0 = $14.
After investigating this issue, we found out that problem caused by wrong sequence of applying cart price rules.
Primarily discount calculating by second rule ($10 for whole cart by coupon) and it using formula sum of discount divided on qty of order items: $10 / 2 = $5 on each product. This make price of both product $19 - $5 = $14, and subtotal of the cart = $28. After this first cart rule applying (minus $18 for one of the product), but because our product price only $14, so discount is only $14, and product's price became 0. Therefore only $24 discount is applied, and the cart total is shown as $14.00.
Primarily discount calculating should be by first cart rule (minus $18 for one of the product), to make product price $19 - $18 = $1, cart total = $20. Then second rule should be applying correctly ($10 for whole cart by coupon), to make cart total $10.00. Total discount amount should be $28.00
@magento I am working on this
@magento give me 2.4-develop instance
Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Bravo, here is your Magento Instance: https://c0a44b9caa363e941ccaf50aad1a6c7d.instances-prod.magento-community.engineering Admin access: https://c0a44b9caa363e941ccaf50aad1a6c7d.instances-prod.magento-community.engineering/admin_20d8 Login: 6a8562de Password: c8629bbcf037
@magento give me 2.4-develop instance
Hi @engcom-Delta. Thank you for your request. I'm working on Magento instance for you.
Hi @engcom-Delta, here is your Magento Instance: https://c0a44b9caa363e941ccaf50aad1a6c7d.instances-prod.magento-community.engineering Admin access: https://c0a44b9caa363e941ccaf50aad1a6c7d.instances-prod.magento-community.engineering/admin_da8d Login: 19d98d99 Password: 3c1428b69d2e
Hi @tiagosampaio ,
Thank you for reporting and collaboration. Verified the issue on Magento 2.4-develop and the issue is not reproducible. Kindly refer the screenshots.
Steps to reproduce -
@engcom-Delta, this still happens in version 2.4.7-p1
.
I have the following cart rules created:
When I go to the cart page and add the products to my cart I have the following result:
The total discount applied to my cart should be $28.00
, not $23.19
.
The Testing Product #2
should receive a fixed $18.00 discount amount, because it belongs to category #4, and the $10.00 should be applied to the whole cart after adding the MY10
discount coupon, according to my rule.
Thanks.
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.