Resurrecting an old thread. I'm working on 1.3.8a, trying to observe events on the shopping cart.
I've been going crazy trying to use the notifier system. I've hacked the shopping_cart.php and would now like to extract my work into an observer so I can port my work more easily to other versions.
My observer is loaded, instantiated, and the constructor is run, so the attach() call completes. However, I never get the update() method fired. I've spent over an hour looking at this and debugging with error_log() calls, but I don't see how the code is supposed to work.
I'm wanting to hook onto NOTIFIER_CART_RESTORE_CONTENTS_START. The docs say I should create an observer and call "$this->attach($this, array('NOTIFIER_CART_RESTORE_CONTENTS_START'));" in the constructor. This succeeds, and $this->observers is added to, but the update() method is not called when the shopping cart calls "$this->notify(....)".
'base' has a $this->observers array, but the array isn't static, right? That is, my observer class (derived from base) has its own 'observers' array, distinct to the shopping_cart instance's observers array. I don't see why calling $this->attach() in my observer (which adds to $this->observers) would achieve the required callback hook when shopping_cart calls $this->notify().
If I change my observer to use "$_SESSION['cart']->attach($this, array('NOTIFIER_CART_RESTORE_CONTENTS_START')" the notification works fine. (also have to change the auto_loader priorities to 90 and 90 - above we were instructed to use 10 and 90 but this breaks use of $_SESSION['cart']->attach()).
I presume this was working fine in 1.3.8a (can't see anything in the changelog)? What could I be doing wrong?
Thanks
Nick



Reply With Quote
