LemonStand Documentation

shop:onBeforeRemoveFromCart event

The shop:onBeforeRemoveFromCart event is triggered before a product is removed from the shopping cart. The event handler function should accept 2 parameters - the cart name and the cart item key. You can use the cart item key for finding an item in the shopping cart. Inside the event handler you can trigger an exception to prevent removing the product from the cart.

Event handler example:

public function subscribeEvents()
{
  Backend::$events->addEvent('shop:onBeforeRemoveFromCart', $this, 'before_remove');
}
 
public function before_remove($cart_name, $key)
{
  $item = Shop_Cart::find_item($key, $cart_name);
  if ($item)
    traceLog('Before remove '.$item->product->name);
}

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