English (United Kingdom)

apply_filters_ref_array( 'vikappointments_switch_payment_save_order', bool $status, int &$id_payment, array &$payments )

Fires after fetching the payment method selected by the customer.


Description

Trigger hook to manipulate the selected method of payment. In case the total to pay is equals to 0.00, this hook won't be triggered.


Parameters

$status

(bool)  True on success, false otherwise.

&$id_payment

(int)  The ID of the payment to use. The $payments argument must own a payment record with that ID, otherwise an error will be thrown. It is possible to set the ID to 0 to skip the payment process.

&$payments

(array)  A list containing all the supported payments. The array must contain the payment that matches the ID of the selected method of payment. In case the ID is going to be assigned to an unpublished gateway, that payment must be pushed within the list.


Example

The following example explains how to pick a payment that is not contained within the list of available payments.

/**
 * Trigger event to manipulate the selected payment gateway.
 *
 * @param  boolean  $status       True on success, false otherwise.
 * @param  integer  &$id_payment  The selected payment gateways.
 * @param  array    &$payments    An array of available payments.
 */
add_filter('vikappointments_switch_payment_save_order', function($status, &$id_payment, &$payments)
{
    // take the payment with ID equals to 5, load event if unpublished ($strict = true)
    $new_payment = VikAppointments::getPayment($id = 5, $strict = false);

    // register payment within the list
    $payments[] = $new_payment;

    // switch selected payment
    $id_payment = 5;

    return $status;
}, 10, 3);

Changelog

Version Description
1.0 Introduced.
Last Update: 2021-08-05
Helpful?

This website uses cookies

This website uses cookies and similar technologies. Some of these technologies are necessary for the proper functioning of the website (Essential). Other technologies are used to evaluate user behavior (Analysis), to integrate external media or for advertising purposes. If you agree, these technologies are activated. For details, please refer to the privacy policy. From this same page you can also update/revoke your consent. If you do not give your consent, only cookies with essential functions will be activated.

We use technologies from the USA on our website. If you give your consent, you therefore consent at the same time to your data being transferred to the USA. We would like to point out that the USA does not have a level of data protection comparable to that of the EU and that any US company can be obliged by state authorities to hand over your data without you having any effective legal protection against this.