woocommerce_store_api_validate_cart_item
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.
Список изменений
С версии 7.1.0 | Введена. |
Где вызывается хук
woocommerce_store_api_validate_cart_item
woocommerce/src/StoreApi/Utilities/CartController.php 680
do_action( 'woocommerce_store_api_validate_cart_item', $product, $cart_item );