woocommerce_add_to_cart_sold_individually_quantity
Filter sold individually quantity for add to cart requests.
Использование
add_filter( 'woocommerce_add_to_cart_sold_individually_quantity', 'wp_kama_woocommerce_add_to_cart_sold_individually_quantity_filter', 10, 5 ); /** * Function for `woocommerce_add_to_cart_sold_individually_quantity` filter-hook. * * @param integer $sold_individually_quantity Defaults to 1. * @param integer $quantity Quantity of the item added to the cart. * @param integer $product_id ID of the product added to the cart. * @param integer $variation_id Variation ID of the product added to the cart. * @param array $cart_item_data Array of other cart item data. * * @return integer */ function wp_kama_woocommerce_add_to_cart_sold_individually_quantity_filter( $sold_individually_quantity, $quantity, $product_id, $variation_id, $cart_item_data ){ // filter... return $sold_individually_quantity; }
- $sold_individually_quantity(int)
- Defaults to 1.
- $quantity(int)
- Quantity of the item added to the cart.
- $product_id(int)
- ID of the product added to the cart.
- $variation_id(int)
- Variation ID of the product added to the cart.
- $cart_item_data(массив)
- Array of other cart item data.
Список изменений
С версии 2.5.0 | Введена. |
Где вызывается хук
woocommerce_add_to_cart_sold_individually_quantity
woocommerce_add_to_cart_sold_individually_quantity
woocommerce/src/StoreApi/Utilities/CartController.php 1201
$request['quantity'] = apply_filters( 'woocommerce_add_to_cart_sold_individually_quantity', 1, $request['quantity'], $product_id, $variation_id, $request['cart_item_data'] );
woocommerce/includes/class-wc-cart.php 1156
$quantity = apply_filters( 'woocommerce_add_to_cart_sold_individually_quantity', 1, $quantity, $product_id, $variation_id, $cart_item_data );