woocommerce_add_to_cart_quantity
Filters the change the quantity to add to cart.
Использование
add_filter( 'woocommerce_add_to_cart_quantity', 'wp_kama_woocommerce_add_to_cart_quantity_filter', 10, 2 ); /** * Function for `woocommerce_add_to_cart_quantity` filter-hook. * * @param number $default_quantity The default quantity. * @param number $product_id The product id. * * @return number */ function wp_kama_woocommerce_add_to_cart_quantity_filter( $default_quantity, $product_id ){ // filter... return $default_quantity; }
- $default_quantity(number)
- The default quantity.
- $product_id(number)
- The product id.
Список изменений
С версии 10.9.0 | Введена. |
Где вызывается хук
woocommerce_add_to_cart_quantity
woocommerce/src/Blocks/BlockTypes/ProductButton.php 128
$quantity_to_add = apply_filters( 'woocommerce_add_to_cart_quantity', $default_quantity, $product->get_id() );
woocommerce/includes/class-wc-cart.php 1037
$quantity = apply_filters( 'woocommerce_add_to_cart_quantity', $quantity, $product_id );