Italian (Italy)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Carrello Take-Away  >  After Apply Discount

do_action_ref_array( 'vikrestaurants_after_apply_cart_discount', float &$value, Discount $discount, float $amount, Item $item )

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.


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.
 */
add_action('vikrestaurants_after_apply_cart_discount', function($value, $discount, $amount, $item) {
    /**
     * @todo it is possible to manipulate $value here to change the applied discount
     */
}, 10, 4);

Changelog

Version Description
1.3 Introduced.
Ultimo aggiornamento: 2024-01-04
Utile?
Potrebbe interessarti:

Questo sito web utilizza i cookie

Questo sito web utilizza cookie e tecnologie simili. Alcune di queste tecnologie sono necessarie per il corretto funzionamento del sito web (essenziali). Altre tecnologie sono utilizzate per valutare il comportamento degli utenti (analisi), per integrare media esterni o per scopi pubblicitari. Se l'utente accetta, queste tecnologie vengono attivate. I dettagli sono riportati nella Privacy Policy. Da questa stessa pagina è inoltre possibile aggiornare/revocare il consenso. Se non si fornisce il consenso, verranno attivati solo i cookie con funzioni essenziali.

Sul nostro sito web utilizziamo tecnologie provenienti dagli Stati Uniti. Pertanto, se acconsentite, acconsentite anche al trasferimento dei vostri dati negli Stati Uniti. Desideriamo sottolineare che gli Stati Uniti non hanno un livello di protezione dei dati paragonabile a quello dell'Unione Europea e che qualsiasi azienda statunitense può essere obbligata dalle autorità statali a consegnare i vostri dati senza che voi abbiate alcuno strumento efficace di protezione legale contro questo.