woocommerce_cart_item_required_stock_is_not_enough хук-фильтрWC 4.6.0

Allows filter if product have enough stock to get added to the cart.

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

add_filter( 'woocommerce_cart_item_required_stock_is_not_enough', 'wp_kama_woocommerce_cart_item_required_stock_is_not_enough_filter', 10, 3 );

/**
 * Function for `woocommerce_cart_item_required_stock_is_not_enough` filter-hook.
 * 
 * @param bool       $has_stock If have enough stock.
 * @param WC_Product $product   Product instance.
 * @param array      $values    Cart item values.
 *
 * @return bool
 */
function wp_kama_woocommerce_cart_item_required_stock_is_not_enough_filter( $has_stock, $product, $values ){

	// filter...
	return $has_stock;
}
$has_stock(true|false)
If have enough stock.
$product(WC_Product)
Product instance.
$values(массив)
Cart item values.

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

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

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

WC_Cart::check_cart_item_stock()
woocommerce_cart_item_required_stock_is_not_enough
woocommerce/includes/class-wc-cart.php 789
if ( apply_filters( 'woocommerce_cart_item_required_stock_is_not_enough', $product->get_stock_quantity() < ( $held_stock + $required_stock ), $product, $values ) ) {

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

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