Your cart is empty!
Add Item
public function onAddPackageItemCart(VAPCartPackages $cart, VAPCartPackagesItem &$item, string &$err) : bool
Fires before adding a new item (package) into the cart.
Description
Trigger hook before adding a new package into the shopping cart.
It is possible to use this hook to prevent the customers from adding specific packages into the cart or to manipulate them at runtime.
Parameters
- $cart
-
(VAPCartPackages) The cart instance.
- &$item
-
(VAPCartPackagesItem) The item that is going to be added into the cart.
- &$err
-
(string) When the item is going to be discarded, it is possible to fill this argument with an error message, which will be prompted to the customer.
$err = 'You are not allowed to purchase this package!'; return false;
Return Value
Boolean. True to add the package into the cart, false to discard it.
Example
/**
* Trigger hook before adding an item into the cart.
*
* @param mixed $cart The cart instance.
* @param mixed &$item The cart item object.
* @param string &$err String used to raise custom errors.
*
* @return boolean True to add the item, false otherwise.
*/
public function onAddPackageItemCart($cart, &$item, &$err)
{
/**
* @todo do stuff here
*/
return true;
}
Changelog
Version | Description |
---|---|
1.7 | Introduced. |
Last Update: 2021-10-06 16:46
Helpful?