woocommerce_add_to_cart_sold_individually_quantity хук-фильтрWC 1.0

Force quantity to 1 if sold individually and check for existing item in cart.

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

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  $1              
 * @param  $quantity       
 * @param  $product_id     
 * @param  $variation_id   
 * @param  $cart_item_data 
 *
 * @return 
 */
function wp_kama_woocommerce_add_to_cart_sold_individually_quantity_filter( $1, $quantity, $product_id, $variation_id, $cart_item_data ){

	// filter...
	return $1;
}
$1
-
$quantity
-
$product_id
-
$variation_id
-
$cart_item_data
-

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

WC_Cart::add_to_cart()
woocommerce_add_to_cart_sold_individually_quantity
CartController::filter_request_data()
woocommerce_add_to_cart_sold_individually_quantity
woocommerce/includes/class-wc-cart.php 1148
$quantity      = apply_filters( 'woocommerce_add_to_cart_sold_individually_quantity', 1, $quantity, $product_id, $variation_id, $cart_item_data );
woocommerce/packages/woocommerce-blocks/src/StoreApi/Utilities/CartController.php 1132
$request['quantity'] = apply_filters( 'woocommerce_add_to_cart_sold_individually_quantity', 1, $request['quantity'], $product_id, $variation_id, $request['cart_item_data'] );

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

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