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

Bypass custom options checks for bundled child items #3995

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/code/core/Mage/Sales/Model/Quote/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ public function representProduct($product)
if ($this->getParentItem() !== $stickWithinParent) {
return false;
}

/**
* Bypass custom options checks for bundled child items
* This prevents cases of adding an additional child item to the quote
* when an existing child product is modified while the bundled item is in a cart
*/
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible that a product that's not simple gets here? I mean, are we sure that there's no other case that needs to proceed to the compareOptions part?

this is a though one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is indeed a tricky bug. Compare items looks at a few keys, excluding buyRequest as shown in the same file:

    /**
     * Not Represent options
     *
     * @var array
     */
    protected $_notRepresentOptions = ['info_buyRequest'];

The goal of the function is to match a newly added product with an existing item in the quote. I don't think a simple product will ever make it to this block, because at this point we've checked:

  • Does the product have a parent product?
  • Does the parent product match the 'child' product we're currently working with

If nothing has changed in the quote_item_options for the particular child, there is no point in comparing options anyways. However in the case where a customer re-adds an item that was existing after a product change, we may have some discrepancies. To add context here, this is an example of the option failing for the bundled product that caused this bug: a:4:{s:5:"price";d:126.5;s:3:"qty";d:2;s:12:"option_label";s:22:"CHILDSKU";s:9:"option_id";i:89;}

There isn't much metadata there, but the price alone causes compareOptions to fail, indicating that this is a new unmatched product and should be added to the quote. I'm definitely open to other suggestions here, as we admittedly aren't heavy users of bundled/configurable products. The other solution of setting the options directly the $product model's options might work, but perhaps would cause issues on child products with user-defined quantities.

}

// Check options
Expand Down
Loading