Switch Payment
apply_filters_ref_array( 'vikappointments_switch_payment_save_packages_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_packages_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.2 | Introduced. |