public function onAfterApplyCartDiscount(float &$value, VAPCartDiscount $discount, float $amount, mixed $item) : void

Fires after applying the discount to apply.


Description

Trigger hook to let external plugins alter the discount to apply at runtime. Manipulating the $value argument will override the default discount calculated by the system. 


Parameters

&$value

(float)  The calculated discount value.

$discount

(VAPCartDiscount)  The instance holding the discount details.

$amount

(float)  The initial cost of the item (without discount).

$item

(mixed)  The instance holding the details of the item to discount.

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   VAPCartDiscount  $discount  The discount instance.
 * @param   float            $amount    The amount to discount.
 * @param   mixed            $item      The item instance.
 *
 * @return  void
 */
public function onAfterApplyCartDiscount(&$value, $discount, $amount, $item)
{
    /**
     * @todo it is possible to override $value to alter the discount
     */
}

Changelog

VersionDescription
1.7 Introduced.
Last Update: 2021-10-06 16:40
Helpful?
This site uses cookies. By continuing to browse you accept their use. Further information