magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.53k stars 9.31k forks source link

Percentage discount on tier price and catalog price rule calculated on original price without selected options. #38750

Open mdkdev opened 5 months ago

mdkdev commented 5 months ago

Preconditions and environment

Steps to reproduce

For a clear example, use the following numbers:

Product Price: 1000 Tier Price: 50% Discount Custom Option Value: -500

image

image

Expected result

The tier price discount is calculated on the price including the custom options. For example:

(1000 - 500) / 2 = 250

Where 1000 is the original product price, 500 is the negative custom option value and 2 is the 50% discount from the tier price.

Actual result

The tier price is calculated based on the original product price without the selected custom options.

(1000 - 500) - 500 = 0

Where 1000 is the original product price, 500 is the negative custom option value and the other 500 is 50% of the original product price (1000).

Additional information

Screencast: https://github.com/magento/magento2/assets/6543944/41b32739-a861-40b8-8a21-19c562a48c03

Scenario:2

The same problem occurs when a catalog price rule is set to (for example) a specific customer group. The discount is then deducted from the original price, which means that the following example results in a 0,- total:

Original Product Price: 1000.00 Cart Price Rule: -50% Custom Option Price: -500

Total Price: (1000 / 2) - 500 = 0.00

This should be a 50% discount on the configured product:

Total Price: (1000 - 500) / 2 = 250.00

magento_cart_price_rule_custom_options.mp4

Release note

No response

Triage and priority

m2-assistant[bot] commented 5 months ago

Hi @mdkdev. Thank you for your report. To speed up processing of this issue, 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:

m2-assistant[bot] commented 5 months ago

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: :point_down:

engcom-Delta commented 5 months ago

Hi @mdkdev ,

Verified the issue on latest 2.4.7 and 2.4-develop, it is reproducible.

Hence, Confirming the issue.

Steps to reproduce:-

1.Configure a simple product with a price 1000 2.Set a tier price with a percentage discount (50%) 3.Set custom option with at least two values, one of the price of the values to 0, and another one to a negative number -500. 4.Go to the frontend, and visit the product. 5.Select the negative custom option value, and the qty that was set on the 50% tier price.

Actual Result:

The tier price is calculated based on the original product price without the selected custom options.

(1000 - 500) - 500 = 0

Where 1000 is the original product price, 500 is the negative custom option value and the other 500 is 50% of the original product price (1000).

https://github.com/magento/magento2/assets/51681379/7b7b9b2b-e9d5-4c58-9d0d-fe191ad1952d

github-jira-sync-bot commented 5 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12004 is successfully created for this GitHub issue.

m2-assistant[bot] commented 5 months ago

:white_check_mark: Confirmed by @engcom-Delta. Thank you for verifying the issue.
Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

mdkdev commented 4 months ago

Hi @engcom-Delta,

Thank you for confirming the issue. The same problem occurs when a catalog price rule is set to (for example) a specific customer group. The discount is then deducted from the original price, which means that the following example results in a 0,- total:

Original Product Price: 1000.00 Cart Price Rule: -50% Custom Option Price: -500

Total Price: (1000 / 2) - 500 = 0.00

This should be a 50% discount on the configured product:

Total Price: (1000 - 500) / 2 = 250.00

https://github.com/magento/magento2/assets/6543944/4369a427-0f28-4175-bc36-7f001c4be20e

Should this be added to a new issue, or is this the right place?

Thank you.

digitalrisedorset commented 4 months ago

@magento I am working on this

engcom-Delta commented 4 months ago

Hi @engcom-Delta,

Thank you for confirming the issue. The same problem occurs when a catalog price rule is set to (for example) a specific customer group. The discount is then deducted from the original price, which means that the following example results in a 0,- total:

Original Product Price: 1000.00 Cart Price Rule: -50% Custom Option Price: -500

Total Price: (1000 / 2) - 500 = 0.00

This should be a 50% discount on the configured product:

Total Price: (1000 - 500) / 2 = 250.00

magento_cart_price_rule_custom_options.mp4 Should this be added to a new issue, or is this the right place?

Thank you.

Hi @mdkdev ,

I have updated the main description and added the scenario in additional information.

Thanks,

digitalrisedorset commented 4 months ago

Hi, I have looked into this issue. The problem is narrowed to 2 javascript files:

My understanding is: we want to inverse this calculation. We want instead the custom option prices to be performed first and then the tier prices would be adjusted after.

These 2 files have their logic intertwined with their UI. Some event subscribers seem to interact from one price to another price type.. I would like enquire on possible documentation to gain awareness of design/architecture around the price calculation on the product detail page. Would we have a diagram to understand the flow with the prices data and the UI on the product page?

JTielemans commented 3 weeks ago

Any news on a fix for this issue?

digitalrisedorset commented 3 weeks ago

Apologies @JTielemans I have not had any inputs on the question I asked. I will unassign me so that it can leave someone else to work on it.