English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Cart  >  Appointments  >  Remove Item Option

apply_filters( 'vikappointments_remove_option_cart', bool $allow, int $id_option, VAPCartItem $item )

Fires before detaching an option from an appointment.


Description

Trigger event before detaching an option from the specified service.

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

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

$index  = $item->indexOf($id_option);
$option = $item->getOptionAt($index);

Parameters

$allow

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

$id_option

(int)  The option ID.

$item

(VAPCartItem)  The item that own the option to delete.


Example

/**
 * Trigger event before detaching an option from the item.
 *
 * @param  boolean  $allow      True to delete the option, false otherwise.
 * @param  integer  $id_option  The option ID.
 * @param  mixed    $item       The cart item instance.
 */
add_filter('vikappointments_remove_option_cart', function($allow, $id_option, $item)
{
    /**
     * @todo check whether the option should be removed or not
     */

    return $allow;
}, 10, 3);

Changelog

Version Description
1.0 Introduced.
Last Update: 2021-10-06
Helpful?