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

Filter cart item data for add to cart requests.

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

add_filter( 'woocommerce_add_cart_item_data', 'wp_kama_woocommerce_add_cart_item_data_filter', 10, 4 );

/**
 * Function for `woocommerce_add_cart_item_data` filter-hook.
 * 
 * @param array   $cart_item_data Array of other cart item data.
 * @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 integer $quantity       Quantity of the item added to the cart.
 *
 * @return array
 */
function wp_kama_woocommerce_add_cart_item_data_filter( $cart_item_data, $product_id, $variation_id, $quantity ){

	// filter...
	return $cart_item_data;
}
$cart_item_data(массив)
Array of other cart item data.
$product_id(int)
ID of the product added to the cart.
$variation_id(int)
Variation ID of the product added to the cart.
$quantity(int)
Quantity of the item added to the cart.

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

CartController::filter_request_data()
woocommerce_add_cart_item_data
WC_Cart::add_to_cart()
woocommerce_add_cart_item_data
woocommerce/packages/woocommerce-blocks/src/StoreApi/Utilities/CartController.php 1159-1165
$request['cart_item_data'] = (array) apply_filters(
	'woocommerce_add_cart_item_data',
	$request['cart_item_data'],
	$product_id,
	$variation_id,
	$request['quantity']
);
woocommerce/includes/class-wc-cart.php 1138
$cart_item_data = (array) apply_filters( 'woocommerce_add_cart_item_data', $cart_item_data, $product_id, $variation_id, $quantity );

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

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