Closed bheindl closed 7 months ago
Hello @bheindl ,
This is an interesting issue that I don't believe we came across in our testing... but I'm vaguely remembering that we found some situations where $quote
could be null at that point, even after calling getQuote()
on the Magento checkout session. This may differ with the underlying implementation of that function across Magento versions, but that's speculation.
At any rate, checking for the quote ID is definitely not a bad idea there, as we certainly don't want to do anything with an empty quote. But, it might be wise to keep the null check as well; something like
if (!$quote || !$quote->getId())
This way we can look at the userContext if the quote is new or somehow null, and avoid an ugly stack trace in the latter case. You're more than welcome to open a PR for this issue if you'd like!
Thanks, Spencer
@sgabhart22 thanks for the quick response and you are completly right, to check both conditions. Created a PR.
This has been added in as part of 5.17.0, closing this out. Thank you @bheindl !
What I expected
Call /V1/amazon-checkout-session/:amazonSessionId/update in headless environment without any php session cookie
Request should pass, as correct quote should be found from usercontext in Amazon\Pay\Helper\Session::getQuoteFromIdOrSession.
What happened instead
Request fails, as Amazon\Pay\Helper\Session::getQuote is returning a new empty quote.
Your setup
Suggested Fix:
Amazon\Pay\Helper\Session::getQuoteFromIdOrSession line 241: Check for
if (!$quote->getId()) {
instead of
if (!$quote) {