woocommerce_cart_item_is_purchasable хук-фильтрWC 7.0.0

Использование

add_filter( 'woocommerce_cart_item_is_purchasable', 'wp_kama_woocommerce_cart_item_is_purchasable_filter', 10, 4 );

/**
 * Function for `woocommerce_cart_item_is_purchasable` filter-hook.
 * 
 * @param bool       $is_purchasable If false, 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_cart_item_is_purchasable_filter( $is_purchasable, $key, $values, $product ){

	// filter...
	return $is_purchasable;
}
$is_purchasable(true|false)
If false, the item will not be added to the cart.
По умолчанию: product's is_purchasable() status
$key(строка)
Cart item key.
$values(массив)
Cart item values e.g. quantity and product_id.
$product(WC_Product)
The product being added to the cart.

Список изменений

С версии 7.0.0 Введена.

Где вызывается хук

WC_Cart_Session::get_cart_from_session()
woocommerce_cart_item_is_purchasable
woocommerce/includes/class-wc-cart-session.php 164
} elseif ( ! apply_filters( 'woocommerce_cart_item_is_purchasable', $product->is_purchasable(), $key, $values, $product ) ) {

Где используется хук в WooCommerce

Использование не найдено.