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

apply_filters( 'vikappointments_remove_packages_item_cart', bool $allow, VAPCartPackages $cart, int $id_package )

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


Description

Trigger hook before deleting a package from the cart.

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

Notice that you can access the information of the package to delete by using the following code.

$index = $cart->indexOf($id_package);
$item  = $cart->getItemAt($index);

Parameters

$allow

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

$cart

(VAPCartPackages)  The cart instance.

$id_package

(int)  The package ID.


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_package  The package ID.
 */
add_filter('vikappointments_remove_packages_item_cart', function($allow, $cart, $id_package)
{
    /**
     * @todo check whether the package should be removed or not
     */

    return $allow;
}, 10, 3);

Changelog

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