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

Fires during validation when adding an item to the cart via the Store API.

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

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

add_action( 'woocommerce_store_api_validate_add_to_cart', 'wp_kama_woocommerce_store_api_validate_add_to_cart_action', 10, 2 );

/**
 * Function for `woocommerce_store_api_validate_add_to_cart` action-hook.
 * 
 * @param \WC_Product $product Product object being added to the cart.
 * @param array       $request Add to cart request params including id, quantity, and variation attributes.
 *
 * @return void
 */
function wp_kama_woocommerce_store_api_validate_add_to_cart_action( $product, $request ){

	// action...
}
$product(\WC_Product)
Product object being added to the cart.
$request(массив)
Add to cart request params including id, quantity, and variation attributes.

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

CartController::validate_add_to_cart()
woocommerce_store_api_validate_add_to_cart
woocommerce/packages/woocommerce-blocks/src/StoreApi/Utilities/CartController.php 294
do_action( 'woocommerce_store_api_validate_add_to_cart', $product, $request );

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

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