You can reproduce the issue by logging in, adding something to cart (starting a quote), logging out again, putting something to the cart and entering checkout.
The quote then still has the customer_id, gustomer_group_id from the previous quote, even the same entity_id.
You can then checkout as guest using the same email address from the previous customer account, but when saving the checkout with Mage_Checkout_Model_Type_Onepage::saveOrder()
, Mage_Checkout_Model_Type_Onepage::getCheckoutMethod()
will return 'login_in' (in app/code/core/Mage/Checkout/Model/Type/Onepage.php lines 802ff.) and start Mage_Checkout_Model_Type_Onepage::_prepareCustomerQuote()
, although being in a guest checkout. The method _prepareCustomerQuote()
will rely on an existing customer session to retrieve customer data, but the session does not exist any more.
To fix this issue, you can simply copy app/code/core/Mage/Checkout/Model/Type/Onepage.php
to app/code/local/Mage/Checkout/Model/Type/Onepage.php
(or rewrite the class using your own custom module), and then replace (inside saveOrder()
method):
switch ($this->getCheckoutMethod()) {
case self::METHOD_GUEST:
$this->_prepareGuestQuote();
break;
case self::METHOD_REGISTER:
$this->_prepareNewCustomerQuote();
$isNewCustomer = true;
break;
default:
$this->_prepareGuestQuote();
break;
}
with this code:
switch ($this->getCheckoutMethod()) {
case self::METHOD_GUEST:
$this->_prepareGuestQuote();
break;
case self::METHOD_REGISTER:
$this->_prepareNewCustomerQuote();
$isNewCustomer = true;
break;
default:
if(Mage::getSingleton('customer/session')->isLoggedIn()) $this->_prepareCustomerQuote();
else $this->_prepareGuestQuote();
break;
}