woocommerce_store_api_validate_cart_item хук-событиеWC 1.0

Fire action to validate add to cart. Functions hooking into this should throw an \Exception to prevent add to cart from occurring.

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

add_action( 'woocommerce_store_api_validate_cart_item', 'wp_kama_woocommerce_store_api_validate_cart_item_action', 10, 2 );

/**
 * Function for `woocommerce_store_api_validate_cart_item` action-hook.
 * 
 * @param \WC_Product $product   Product object being added to the cart.
 * @param array       $cart_item Cart item array.
 *
 * @return void
 */
function wp_kama_woocommerce_store_api_validate_cart_item_action( $product, $cart_item ){

	// action...
}
$product(\WC_Product)
Product object being added to the cart.
$cart_item(массив)
Cart item array.

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

CartController::validate_cart_item()
woocommerce_store_api_validate_cart_item
woocommerce/packages/woocommerce-blocks/src/StoreApi/Utilities/CartController.php 633
do_action( 'woocommerce_store_api_validate_cart_item', $product, $cart_item );

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

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