Ensures that the quote's customer is set on newly created quotes#5344
Open
azambon wants to merge 13 commits into
Open
Ensures that the quote's customer is set on newly created quotes#5344azambon wants to merge 13 commits into
azambon wants to merge 13 commits into
Conversation
I've encountered a bug where upon first creating a new quote, the quote's customer_id field was not set. Later requests then attempted to load the active quote for the same customer but, since the quote didn't have the customer_id field set, the load operation didn't find anything and a second quote was created. This should make sure that the customer_id field is set right away even for newly created quotes whenever a cusotmer is available.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a checkout-session edge case where a newly created quote can remain without customer_id, which can lead to duplicate active quotes for the same customer (especially in persistent/“remember me” scenarios).
Changes:
- Adjusts
Mage_Checkout_Model_Session::getQuote()to set a customer on the quote even when the quote is newly created (noquote_idyet).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Contributor
|
Thanks. Pls run |
This reverts commit 44b95ee.
…the quote's customer data is updated
Contributor
|
|
| } | ||
|
|
||
| if ($this->getQuoteId() && ($customerSession->isLoggedIn() || $this->_customer)) { | ||
| if ((!is_null($this->getQuoteId()) || !$quote->getCustomerId()) && ($customerSession->isLoggedIn() || $this->_customer)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



I've recently encountered a bug where, upon first creating a new quote, the quote's customer_id field was not set.
Later requests by the same customer (possibly sent from a different device with a different session cookie) then attempted to load the active quote for the same customer_id but, since the quote didn't have the customer_id field set, the load operation didn't find anything and a second quote was created.
And then, somehow, the first quote was populated with the customer_id value.
The end result was that we ended up with multiple active quotes for the same customer in the same store view, which should not happen.
This fix should make sure that the customer_id field is set right away even for newly created quotes whenever a customer is available.
Unfortunately I don't have a testing scenario. In our site we implemented a "remember me" feature that uses Magento's persistent session, and I suspect that such "remember me" is what causes this bug to surface.
Having said that, the fix is just a couple lines of code, so it should be easy to inspect. And I haven't seen any new occurrences of the issue ever since applying this fix so... your call.