English (United Kingdom)

do_action( 'vikrestaurants_remove_take_away_cart_item', Item $item, Cart $cart )

Fires while removing an item from the cart.


Description

Plugins attached to this event can manipulate the default behavior of the system whenever an item is going to be removed from the cart. An item is considered removed only when the remaining units of the item are equal to 0. The event does not fire in case the quantity gets decreased and there are still other units available in cart.

It is possible to throw an exception to abort the deleting process.


Parameters

$item

(Item) The object holding the details of the item. This class is part of the E4J\VikRestaurants\TakeAway\Cart namespace.

$cart

(Cart) The object holding the cart items. This class is part of the E4J\VikRestaurants\TakeAway\Cart namespace.


Example

/**
 * Fires an action whenever an item is going to be removed from the cart.
 * 
 * @param   Item  $item
 * @param   Cart  $cart
 * 
 * @throws  Exception  To abort the removing process.
 */
add_action('vikrestaurants_remove_take_away_cart_item', function($item, $cart) {
    // do something here...
}, 10, 2);

Changelog

Version Description
1.3.3 Introduced.
Last Update: 2024-05-14
Helpful?
See Also: