wooocommerce_store_api_validate_add_to_cart action-hook . WC 1.0
Fire action to validate add to cart. Functions hooking into this should throw an \Exception to prevent add to cart from occuring.
Usage
add_action( 'wooocommerce_store_api_validate_add_to_cart', 'action_function_name_3631', 10, 2 ); function action_function_name_3631( $product, $request ){ // action... }
- $product(\WC_Product)
- Product object being added to the cart.
- $request(array)
- Add to cart request params including id, quantity, and variation attributes.
Where the hook is called
wooocommerce_store_api_validate_add_to_cart
woocommerce/packages/woocommerce-blocks/src/StoreApi/Utilities/CartController.php 225
do_action( 'wooocommerce_store_api_validate_add_to_cart', $product, $request );