wc_protected_product_add_to_cart( bool $passed, int $product_id )
Prevent password protected products being added to the cart.
Description Description
Parameters Parameters
- $passed
-
(Required) Validation.
- $product_id
-
(Required) Product ID.
Return Return
(bool)
Source Source
File: includes/wc-cart-functions.php
function wc_protected_product_add_to_cart( $passed, $product_id ) { if ( post_password_required( $product_id ) ) { $passed = false; wc_add_notice( __( 'This product is protected and cannot be purchased.', 'woocommerce' ), 'error' ); } return $passed; }