0

Save custom data to ('checktout/session') when product added to cart and remove when removed So i need to add custom data for each product when customer adds it to card and remove it when customer removes from cart. What i have done so far was creating observer that fires up when customer adds product to cart, but it doesnt save my data in global ('checkout/session').

In observer i can see my custom data saved.

This is the code in observer:

$quoteId = Mage::getSingleton('checkout/session')->getQuote()->getEntityId();
    $quote = Mage::getModel('sales/quote')->load($quoteId);

    $carDetails = Mage::getSingleton('core/session')->getCarDetails();
    if(empty($carDetails)){
        $carDetails = 'No Car in Search';
    }

    $quoteItems = $quote->getAllItems();

    foreach ($quoteItems as $quoteItem){

        $product = $quoteItem->getProduct();

        $quoteItems = $product->setCarDetails($carDetails);

        echo'<pre>';print_r($product->getId());
        echo'<pre>';print_r($product->getCarId());die();
    }

Your Answer

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

Browse other questions tagged or ask your own question.