woocommerce_store_api_product_quantity_limit
Filters the quantity limit for a product being added to the cart via the Store API.
Filters the variation option name for custom option slugs.
Использование
add_filter( 'woocommerce_store_api_product_quantity_limit', 'wp_kama_woocommerce_store_api_product_quantity_limit_filter', 10, 2 ); /** * Function for `woocommerce_store_api_product_quantity_limit` filter-hook. * * @param integer $quantity_limit Quantity limit which defaults to 9999 unless sold individually. * @param \WC_Product $product Product instance. * * @return integer */ function wp_kama_woocommerce_store_api_product_quantity_limit_filter( $quantity_limit, $product ){ // filter... return $quantity_limit; }
- $quantity_limit(int)
- Quantity limit which defaults to 9999 unless sold individually.
- $product(\WC_Product)
- Product instance.
Список изменений
С версии 6.8.0 | Введена. |
Где вызывается хук
woocommerce_store_api_product_quantity_limit
woocommerce/src/StoreApi/Utilities/QuantityLimits.php 162
return apply_filters( 'woocommerce_store_api_product_quantity_limit', max( min( array_filter( $limits ) ), 1 ), $product );