Hi,

I want to block certain product from being added to cart (based on existing cart's content). So, I thought I'll do this via an observer, that when triggered, looks at the cart's content and marks it as invalid for checkout. However... it doesn't seem to be working. Any thoughts about what I'm doing wrong?

My code is similar to (in this case I want to see an error when adding product id 1 IF there are other products in cart already):

class order_restrict extends base
{
function __construct() {
global $zco_notifier;

$zco_notifier->attach($this, array('NOTIFIER_CART_ADD_CART_END'));
}


function update(&$class, $eventID, $paramsArray = array())
{
global $messageStack;

switch ($eventID)
{
case 'NOTIFIER_CART_ADD_CART_END':
$cart = $_SESSION['cart'];
$product1_id = zen_get_uprid(1, '');
$products = $cart->get_products();

if (sizeof($products)>1 && $cart->in_cart($product1_id) )
{
$_SESSION['valid_to_checkout'] = false;
$messageStack->add('shopping_cart', TEXT_CANT_ADD_THIS, 'error');
$_SESSION['cart_errors'] .= TEXT_CANT_ADD_THIS. '<br />';
}
break;

default:
break;
}
}
}


thanks!