1

I'm trying really hard to learn Magento, but I need some help.

I want to track product quotes changes in cart after clicking to "update cart" button. I found nice events called checkout_cart_update_items_after and checkout_cart_update_items_before.

But I don't know how to get info about cart quotes changes in observer.

The best I achieved was

public function Mytestupd($observer) {
    $product = $observer->getData('cart');
    $quote = $product->getData('quote');
    $items = $quote->getAllVisibleItems();

    foreach($items as $item) {
        $prsku .= $item->getQty()." ";
    } 
    }

Which of course just gives me old (or new, depends on event) quote of each item.

At the end I'd like to do

echo Mage::getSingleton('checkout/session')->addSuccess("Cart Updated, your changes are: ".$changes);

where $changes is something like

productOne: 3 items added;
productTwo: 4 items removed

I hope that was clear enough and someone will help me!

2

It's great to have session variables. So I could do

Mage::getSingleton('core/session')->setCartItems($myVals);

in checkout_cart_update_items_before event Observer and later do

$oldcart = Mage::getSingleton('core/session')->getCartItems();

in checkout_cart_update_items_after event Observer

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.