Italian (Italy)
Knowledge Base  >  Vik Restaurants  >  Hooks  >  Pagamento  >  Search Available

apply_filters( 'vikrestaurants_search_available_payment', bool $accept, object $payment, string $group )

Fires while checking whether a payment gateway can be used or not.


Description

Trigger hook to let external plugins apply additional filters while searching for a compatible payment gateway. The filter applies once for each payment gateway separately.

When this hook is triggered, the system already validated the standard conditions and the payment gateway has been approved for the usage.

In case the payment is discarded, it won't be reported within the selection list of payments.


Parameters

$accept

(bool)  Use false to discard the payment gateway.

$payment

(object)  An object holding the details of the payment to check.

$group

(string)  The section in which the customer is paying ("restaurant" or "takeaway").


Example

The example below automatically turns off a specific payment during Summer.

/**
 * Trigger event to let external plugins apply additional filters while 
 * searching for a compatible payment gateway.
 * The hook will be executed only in case all the other filters
 * accepted the payment for the usage.
 *
 * @param  bool    $accept   True to accept the payment, false to discard it.
 * @param  object  $payment  The payment database record.
 * @param  string  $group    The group to check ("restaurant" or "takeaway").
 */
add_filter('vikrestaurants_search_available_payment', function($accept, $payment, $group) {
    if ($payment->id != 5) {
        // go ahead
        return $accept;
    }

    // payment found, get current month
    $mon = (int) date('n');

    // make sure we are not in Summer
    if (in_array($mon, [6, 7, 8]) {
        // discard payment
        $accept = false;
    }

    return $accept;
}, 10, 3);

Changelog

Version Description
1.3 The $group argument has been changed from int to string and the accepted types have been changed accordingly: 1 in "restaurant"; 2 in "takeaway".
Removed the $user and $total arguments as they were out of context.
1.2 Introduced.
Ultimo aggiornamento: 2023-12-27
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.