English (United Kingdom)

apply_filters( 'vikappointments_remove_item_cart', bool $allow, VAPCart $cart, int $id_service, int $id_employee, string $checkin )

Fires before deleting an item (service) from the cart.


Description

Trigger hook before deleting a service from the cart.

It is possible to use this hook, in example, to prevent the customers from deleting specific services.

Notice that you can access the information of the appointment by using the following code.

$index = $cart->indexOf($id_service, $id_employee, $checkin);
$item  = $cart->getItemAt($index);

Parameters

$allow

(bool)  True to delete the service from the cart, false to keep it.

$cart

(VAPCart)  The cart instance.

$id_service

(int)  The service ID.

$id_employee

(int)  The employee ID.

$checkin

(string)  The check-in date time (in UTC).


Example

/**
 * Trigger event before deleting an item from the cart.
 *
 * @param  boolean  $allow        True to delete the item, false otherwise.
 * @param  mixed    $cart         The cart instance.
 * @param  integer  $id_service   The service ID.
 * @param  integer  $id_employee  The employee ID.
 * @param  string   $checkin      The check-in date time (UTC).
 */
add_filter('vikappointments_remove_item_cart', function($allow, $cart, $id_service, $id_employee, $checkin)
{
    /**
     * @todo check whether the appointment should be removed or not
     */

    return $allow;
}, 10, 5);

Changelog

Version Description
1.0 Introduced.
Last Update: 2021-08-04
Helpful?
See Also:
This site uses cookies. By continuing to browse you accept their use. Further information