woocommerce_pre_remove_cart_item_from_session
Allow 3rd parties to validate this item before it's added to cart and add their own notices.
Использование
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.
По умолчанию: false - $key(строка)
- Cart item key.
- $values(массив)
- Cart item values e.g. quantity and product_id.
- $product(WC_Product)
- The product being added to the cart.
Список изменений
С версии 3.6.0 | Введена. |
Где вызывается хук
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 ) ) {