Your cart is empty!
After Apply Discount
public function onAfterApplyCartDiscount( float &$value, Discount $discount, float $amount, Item $item ) : void
Fires after calculating the discount applied by a coupon or a deal to a specific item.
Description
Plugins attached to this hook can manipulate the discount amount calculated by the system for a specific item.
NOTE: calling $discount->apply()
in this hook will result in recursion.
Parameters
- &$value
-
(float) The discount calculated by the system, passed by reference.
- $discount
-
(Discount) The object holding the discount information. This class is part of the
E4J\VikRestaurants\TakeAway\Cart\Deals
namespace. - $amount
-
(float) The initial amount to discount.
- $item
-
(Item) The object holding the details of the item to discount. This class is part of the
E4J\VikRestaurants\TakeAway\Cart
namespace.
Return Value
None.
Example
/**
* Trigger event to let external plugins alter the discount to apply at runtime.
*
* @param float &$value The calculated discount value.
* @param Discount $discount The discount information.
* @param float $amount The initial amount to discount.
* @param Item $item The item to discount.
*
* @return void
*/
public function onAfterApplyCartDiscount($value, $discount, $amount, $item)
{
/**
* @todo it is possible to manipulate $value here to change the applied discount
*/
}
Changelog
Version | Description |
---|---|
1.9 | Introduced. |
Last Update: 2023-12-29 14:15
Helpful?