Triggered before a product is added to the cart.
You can use the event handler to perform custom validation when a customer clicks the Add to Cart button.
Inside the handler you can trigger an exception in order to prevent adding a product to the cart. Usage example:
public function subscribeEvents()
{
Backend::$events->addEvent('shop:onBeforeAddToCart', $this, 'before_add');
}
public function before_add($cart_name, $product, $quantity, $options, $extra_options, $custom_data, $bundle_data, $master_bundle_data)
{
traceLog('Add '.$product->name);
if ($product->sku == '123')
throw new Phpr_ApplicationException('You cannot add this product to the cart!');
}