I am not sure how quotes work in Magento. I saw that a quote id is assigned to customer when is created. Sometimes I see in sales_flat_quote table that for one customer there are 2 lines there...I mean there are 2 quotes.(actually one has store_id=0 and one store_id=1) When a users log in through API (custom code) it seems that a new quote is assigned to. I don't get what is happening..or how should this work..

  • is there any other information that is necessary to assist you with this question? If not, please answer it with your own answer or mark another answer as accepted.
    – philwinkle
    Feb 28 '14 at 23:00

A quote is actually a 'cart' object.
A customer can have many quotes. One for each website.
the quote object is not created when the customer is created. It is created when the customer adds the first product to the cart.
Also a quote is not necessarily assigned to a customer. You can have a quote when browsing the website as guest.
In that case the quote remains in the db after the session expires.

  • Thank you for your response! One quote for each site which is given by store_id. When store_id=0 what does it mean? I have just tested again: I created a new customer and in sales_flat_quote table I see the new customer id. Am I wrong that this mean that a quote is assigned? Regarding the unassigned quote, I know that.
    – Denisa
    Jan 29 '14 at 11:13
  • Store id 0 means 'Admin'. It means there is a quote created from the admin panel (and maybe the API - not sure about this) for that customer.
    – Marius
    Jan 29 '14 at 11:13
  • I have a method with this code $session = Mage::getSingleton('customer/session'); $session->loginById($customer_id); $quoteID = Mage::getSingleton("checkout/session")->getQuote()->getId(); return "Customer ID: ". Mage::getSingleton('customer/session')->getCustomerId().' Quote ID: '.$quoteID; Let's say I don't have any quote yet in sales_flat_quote. After I call my method..I will receive a quote id and in the table I see a new record for my customer with store_id=0. I don't get where the quote is created.
    – Denisa
    Jan 29 '14 at 11:46
  • The quote is created when you call Mage::getSingleton("checkout/session")->getQuote(). Check how the method Mage_Checkout_Model_Session::getQuote works. If there is a quote for the specified customer it returns it. If not, it creates one and returns it.
    – Marius
    Jan 29 '14 at 11:51
  • Yes..my mistake I didn't look at that method. It seems that the problem is with Mage::app()->getStore()->getId()...which is 1 if I use website and is 0 in my method which extends API. So, even if my customer has already a quote which has been created from website, when I call my method it will be created a new quote with store_id=0. It is possible to get the quote id for my customer (with store_id=1) instead of creating a new one? What if there are multiple stores? How can I know what quote to return?
    – Denisa
    Jan 29 '14 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.