Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6852369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:21:45+00:00 2026-05-27T01:21:45+00:00

I’m trying to create different checkout sessions for the logged in customer at a

  • 0

I’m trying to create different checkout sessions for the logged in customer at a store level, rather than at the site level.

We have a site with 2 stores. When a user adds a product to the cart, we want to show that product in the cart only for that store. But currently switching between stores will show up products of other stores previously added to the cart.

After some research I found that whenever a user logs in to a store, a record is created in the sales_flat_quote table for the logged in customer, which is common for all the stores in that site. So I need to create a new record in the sales_flat_quote table when the user switches stores.

I found that the loadByCustomerId() function in class Mage_Sales_Model_Mysql4_Quote is what creates the new record in the sales_flat_quote table. But all I see is a select query:

$read = $this->_getReadAdapter();
$select = $this->_getLoadSelect('customer_id', $customerId, $quote)
                ->where('is_active=1')
                ->order('updated_at desc')
                ->limit(1);
$data = $read->fetchRow($select);

I don’t understand how the select query is creating the record in the sales_flat_quote table.

Could someone guide as to how to create a new record in this table for the logged in customer when he/she switches to an other store under the same site?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:21:45+00:00Added an answer on May 27, 2026 at 1:21 am

    We have a site with 2 stores. When a user adds a product to the cart,
    we want to show that product in the cart only for that store. But
    currently switching between stores will show up products of other
    stores previously added to the cart.

    Which is correct.

    It looks like you want to separate carts for store definitions, which both are connected to the very same website definition in Magento.

    In Magento, all stores defined within the same website do always share the very same cart.

    That’s by-design.

    To achieve cart separation you would need to change your Magento setup to have two websites and one store per website. Otherwise you’ll run into endless issues separating the two stores (like the issue you’re having now), I guess.

    That said, I’ll nevertheless try to answer your concrete question:

    I don’t understand how the select query is creating the record in the
    sales_flat_quote table.

    A SELECT query usually never ever will create a record; it’s thought to read data.

    Have a look at Mage_Checkout_Model_Session::loadCustomerQuote():

    $customerQuote = Mage::getModel('sales/quote')
        ->setStoreId(Mage::app()->getStore()->getId())
        ->loadByCustomer(Mage::getSingleton('customer/session')->getCustomerId());
    

    This is what leads to the call of Mage_Sales_Model_Mysql4_Quote::loadByCustomerId() you’re talking about. It just loads the customers quote (if any), nothing else.

    Creation/update of the record happens by calling the quotes save() method.

    Magento EE 1.11.0.0 for example saves the record this way:

    if ($customerQuote->getId() && $this->getQuoteId() != $customerQuote->getId()) {
        if ($this->getQuoteId()) {
            $customerQuote->merge($this->getQuote())
                ->collectTotals()
                ->save();   // <- either this 
        }
    
        $this->setQuoteId($customerQuote->getId());
    
        if ($this->_quote) {
            $this->_quote->delete();
        }
        $this->_quote = $customerQuote;
    } else {
        $this->getQuote()->getBillingAddress();
        $this->getQuote()->getShippingAddress();
        $this->getQuote()->setCustomer(Mage::getSingleton('customer/session')->getCustomer())
            ->setTotalsCollectedFlag(false)
            ->collectTotals()
            ->save();   // <- or that does the save
    }
    

    You didn’t mention the Magento version you use, so your mileage may vary, but the principle will still remain the same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.