English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Cart  >  Appointments  >  After Apply Discount

apply_filters_ref_array( 'vikappointments_after_apply_cart_discount', bool $status, float &$value, VAPCartDiscount $discount, float $amount, mixed $item )

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

$status

(bool)  True on success, false otherwise.

&$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.


Example

/**
 * Trigger event to let external plugins alter the discount to apply at runtime.
 *
 * @param  boolean          $status    True on success, false otherwise.
 * @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.
 */
add_filter('vikappointments_after_apply_cart_discount', function($status, &$value, $discount, $amount, $item)
{
    /**
     * @todo it is possible to override $value to alter the discount
     */

    return $status;
}, 10, 5);

Changelog

Version Description
1.2 Introduced.
Last Update: 2021-10-06
Helpful?