woocommerce_store_api_product_quantity_(value_type) хук-фильтрWC 6.8.0

Filters the quantity minimum for a cart item in Store API. This allows extensions to control the minimum qty of items already within the cart.

The suffix of the hook will vary depending on the value being filtered. For example, minimum, maximum, multiple_of, editable.

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

add_filter( 'woocommerce_store_api_product_quantity_(value_type)', 'wp_kama_woocommerce_store_api_product_quantity_value_type_filter', 10, 3 );

/**
 * Function for `woocommerce_store_api_product_quantity_(value_type)` filter-hook.
 * 
 * @param mixed       $value     The value being filtered.
 * @param \WC_Product $product   The product object.
 * @param array|null  $cart_item The cart item if the product exists in the cart, or null.
 *
 * @return mixed
 */
function wp_kama_woocommerce_store_api_product_quantity_value_type_filter( $value, $product, $cart_item ){

	// filter...
	return $value;
}
$value(разное)
The value being filtered.
$product(\WC_Product)
The product object.
$cart_item(массив|null)
The cart item if the product exists in the cart, or null.

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

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

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

QuantityLimits::filter_value()
woocommerce_store_api_product_quantity_(value_type)
woocommerce/src/StoreApi/Utilities/QuantityLimits.php 210
return apply_filters( "woocommerce_store_api_product_quantity_{$value_type}", $value, $product, $cart_item );

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

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