Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Change quote session
 
CBC
Member
 
Total Posts:  48
Joined:  2008-01-15
Spain
 

Hello,

I need some help to change the session quote.

I have many rows on sales_quote for one customer. I can show them accurately, and each sales_quote has a button to create the order.
The problem is that when I want to delete an item or to change its qty, I can only change the first sales_quote row, because it was saved in session. How can I change the quote session without reloading the page?.

Thanks a lot.

 
Magento Community Magento Community
Magento Community
Magento Community
 
CBC
Member
 
Total Posts:  48
Joined:  2008-01-15
Spain
 

I have this code:

/**
     * Update cart items
     *
     * @param   array $data
     * @return  Mage_Checkout_Model_Cart
     */
    public function updateItems($data)
    
{
        $checkoutobject 
= new Mage_Checkout_Block_Cart();
        foreach(
$checkoutobject->getSalesQuote() as $_quote){
            Mage
::getSingleton('checkout/session')->unsetAll();
            
Mage::getSingleton('checkout/session')->setQuoteId($_quote->getId());
            
Mage::getSingleton('checkout/session')->getQuote();

            foreach (
$data as $itemId => $itemInfo{
                                 $item 
$this->getQuote()->getItemById($itemId);
       .......

getSalesQuote is a method that has as output all quotes of a customer, but it only updates the items of the first quote.

Thanks a lot.

 
Magento Community Magento Community
Magento Community
Magento Community
 
CBC
Member
 
Total Posts:  48
Joined:  2008-01-15
Spain
 

Hello:

I have just been able to change the session to update all the quotes. I was trying to change the wrong item… I changed the session but only saving one quote at a time.

Now, I have got this code correctly working:

/**
     * Update shoping cart data action
     */
    public function updatePostAction()
    
{
        
try {
            $cartData 
$this->getRequest()->getParam('cart');
            if (
is_array($cartData)) {
                
                $checkoutobject 
= new Mage_Checkout_Block_Cart();
                foreach(
$checkoutobject->getSalesQuote() as $_quote){

                    Mage
::getSingleton('checkout/session')->unsetAll();
                    
Mage::getSingleton('checkout/session')->setQuoteId($_quote->getId());
                    
Mage::getSingleton('checkout/session')->getQuote();

                    
$cart $this->_getCart();
                    
$cart->updateItems($cartData)
                    ->
save();
                
}
            }
            Mage
::getSingleton('checkout/session')->setCartWasUpdated(true);
        
}

Greetings!
 
Magento Community Magento Community
Magento Community
Magento Community
 
nileshti
Jr. Member
 
Total Posts:  1
Joined:  2013-03-07
 

Dear CBC,

Thanks for this post.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top