English (United Kingdom)

apply_filters( 'vikappointments_init_save_subscription_order', bool $status, mixed $cart )

Fires at the beginning of the saving process.


Description

Trigger hook to manipulate the cart instance while saving a subscription order. Here's possible to manipulate the cart instance.

This is the first hook that triggers after clicking the "Confirm Order" button.


Parameters

$status

(bool)  True on success, false otherwise.

$cart

(VikAppointmentsModelSubscrcart)  The cart instance.


Example

Here's explained how it is possible to manipulate the selected subscription or the payment method.

/**
 * Trigger hook to manipulate the cart instance.
 *
 * @param  boolean  $status  True on success, false otherwise.
 * @param  mixed    $cart    The cart instance.
 */
add_filter('vikappointments_init_save_subscription_order', function($status, $cart)
{
    // set payment with ID #5
    $cart->setPayment(5);

    // set subscription plan with ID #2
    $cart->setSubscription(2);

    // apply a custom discount
    $cart->addDiscount(new VAPCartDiscount(
        'custom-discount', 20.00, $percent = true
    ));

    return $status;
}, 10, 2);

Changelog

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