woocommerce_pre_remove_cart_item_from_session filter-hookWC 3.6.0

Allow 3rd parties to validate this item before it's added to cart and add their own notices.

Usage

add_filter( 'woocommerce_pre_remove_cart_item_from_session', 'wp_kama_woocommerce_pre_remove_cart_item_from_session_filter', 10, 4 );

/**
 * Function for `woocommerce_pre_remove_cart_item_from_session` filter-hook.
 * 
 * @param bool       $remove_cart_item_from_session If true, the item will not be added to the cart.
 * @param string     $key                           Cart item key.
 * @param array      $values                        Cart item values e.g. quantity and product_id.
 * @param WC_Product $product                       The product being added to the cart.
 *
 * @return bool
 */
function wp_kama_woocommerce_pre_remove_cart_item_from_session_filter( $remove_cart_item_from_session, $key, $values, $product ){

	// filter...
	return $remove_cart_item_from_session;
}
$remove_cart_item_from_session(true|false)
If true, the item will not be added to the cart.
Default: false
$key(string)
Cart item key.
$values(array)
Cart item values e.g. quantity and product_id.
$product(WC_Product)
The product being added to the cart.

Changelog

Since 3.6.0 Introduced.

Where the hook is called

WC_Cart_Session::get_cart_from_session()
woocommerce_pre_remove_cart_item_from_session
woocommerce/includes/class-wc-cart-session.php 152
if ( apply_filters( 'woocommerce_pre_remove_cart_item_from_session', false, $key, $values, $product ) ) {

Where the hook is used in WooCommerce

Usage not found.