magento2
magento2 copied to clipboard
Customizable Options in Cart Incorrectly Update All Instances of a Product
Preconditions and environment
2.4.7-p2
Steps to reproduce
- Create a simple product with at least 2 customizable options (both as dropdowns).
- Add the product to the cart with the following selections:
- Dropdown 1: Value A
- Dropdown 2: Value C
- Add the same product to the cart again but with different selections:
- Dropdown 1: Value B
- Dropdown 2: Value D
Note that both products are correctly added as separate items in the cart.
- Go to the cart view.
- Edit the customizable options of one of the products in the cart.
Expected result
Only the selected product in the cart should update its customizable options according to the changes made.
Actual result
Both products in the cart are updated to reflect the same customizable options as the product being edited, regardless of their previous settings.
Additional information
A workaround is to remove the affected product and re-add it with the correct options, but this is not an ideal solution.
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.
- [X] 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”.
Hi @Hurrpadurr. 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:
@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.
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, join the Community Contributions Triage session to discuss the appropriate ticket.
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: :point_down:
- [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXXlabel to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced 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: Confirmedonce verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @Hurrpadurr,
Thanks for your reporting and collaboration.
We have verified the issue in Latest 2.4-develop instance and the issue is reproducible.Kindly refer the attached video.
https://github.com/user-attachments/assets/38cdb4d4-5b48-4140-91ad-a529bbdbb191
Both products in the cart are updated to reflect the same customizable options as the product being edited, regardless of their previous settings.
Hence Confirming the issue.
Thanks.
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12846 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
From what I can tell, the \Magento\Quote\Model\Quote\Item\Compare::compare() function was modified to add a SKU check to the beginning of the function.
if ($target->getSku() !== null && $target->getSku() === $compared->getSku()) {
return true;
}
This causes the function to return before the checks for custom options and such which should differentiate the quote items and not simply merge them.
I have no idea what this check was added to solve, but I'm going to test simply removing it in an override.
I think the only situation I could see the above code being necessary is if somehow products sharing a SKU from different storefronts were added to the cart such that they would have different product IDs. I'm not sure what scenario would result in this.
I guess if you reworked it to run the compareOptions() checks IF the product IDs are identical. Then do the SKU check. But even in that case I think you'd want to check the custom options and not necessarily just merge the same-sku-different-id product. I think you'd only want to do that if the product(s) in question had no custom options.
As far as I know it shouldn't be possible for multiple products in one storefront to have the same SKU though, so this check does still seem unnecessary. Maybe I'm wrong.
Something that worked for me: I had a custom setting in the HandleCartAddAfter, and no matter if the custom setting was on or off the price was updated for all items in the cart. What fixed it was assigning the custom option in the HandleCartAddBefore. Hopefully this helps someone
Patch for the quote module:
--- Model/Quote/Item/Compare.php.org 2025-10-07 13:29:35
+++ Model/Quote/Item/Compare.php 2025-10-07 13:29:51
@@ -68,8 +68,8 @@
*/
public function compare(Item $target, Item $compared)
{
- if ($target->getSku() !== null && $target->getSku() === $compared->getSku()) {
- return true;
+ if ($target->getSku() !== null && $target->getSku() !== $compared->getSku()) {
+ return false;
}
if ($target->getProductId() != $compared->getProductId()) {
Using custom options does not necessarily means the SKU differs. For example if you have a custom text for adding a label on the packaging, this field does not alter the SKU. Hence we should compare the options even if the SKU's match.