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

Add item after merging with $cart_item_data - hook to allow plugins to modify cart item.

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

add_filter( 'woocommerce_add_cart_item', 'wp_kama_woocommerce_add_cart_item_filter', 10, 2 );

/**
 * Function for `woocommerce_add_cart_item` filter-hook.
 * 
 * @param  $array_merge   
 * @param  $cart_item_key 
 *
 * @return 
 */
function wp_kama_woocommerce_add_cart_item_filter( $array_merge, $cart_item_key ){

	// filter...
	return $array_merge;
}
$array_merge
-
$cart_item_key
-

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

WC_Cart::add_to_cart()
woocommerce_add_cart_item
CartController::add_to_cart()
woocommerce_add_cart_item
woocommerce/includes/class-wc-cart.php 1259-1274
$this->cart_contents[ $cart_item_key ] = apply_filters(
	'woocommerce_add_cart_item',
	array_merge(
		$cart_item_data,
		array(
			'key'          => $cart_item_key,
			'product_id'   => $product_id,
			'variation_id' => $variation_id,
			'variation'    => $variation,
			'quantity'     => $quantity,
			'data'         => $product_data,
			'data_hash'    => wc_get_cart_item_data_hash( $product_data ),
		)
	),
	$cart_item_key
);
woocommerce/packages/woocommerce-blocks/src/StoreApi/Utilities/CartController.php 106-121
$cart->cart_contents[ $cart_id ] = apply_filters(
	'woocommerce_add_cart_item',
	array_merge(
		$request['cart_item_data'],
		array(
			'key'          => $cart_id,
			'product_id'   => $this->get_product_id( $product ),
			'variation_id' => $this->get_variation_id( $product ),
			'variation'    => $request['variation'],
			'quantity'     => $request_quantity,
			'data'         => $product,
			'data_hash'    => wc_get_cart_item_data_hash( $product ),
		)
	),
	$cart_id
);

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

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