LemonStand Documentation

shop:onBeforeSetCartQuantity event

The shop:onBeforeSetCartQuantity event is triggered before a product quantity in the cart is changed. The event handler function should accept 3 parameters - the cart name, the cart item key and the new quantity value. You can use the cart item key for finding an item in the shopping cart. Inside the event handler you can trigger an event to prevent changing the quantity.
Event handler example:

public function subscribeEvents()
{
  Backend::$events->addEvent('shop:onBeforeSetCartQuantity', $this, 'before_set_cart_quantity');
}
 
public function before_set_cart_quantity($cart_name, $key, $value)
{
  $item = Shop_Cart::find_item($key, $cart_name);
  if ($item)
    traceLog('New quantity value for '.$item->product->name.': '.$value);
}

Next: shop:onExtendProductsToolbar event
Previous: shop:onAfterRemoveFromCart event
Return to Handling LemonStand events