wc_protected_product_add_to_cart()
Prevent password protected products being added to the cart.
No Hooks.
Return
true|false
.
Usage
wc_protected_product_add_to_cart( $passed, $product_id );
- $passed(true|false) (required)
- Validation.
- $product_id(int) (required)
- Product ID.
wc_protected_product_add_to_cart() wc protected product add to cart code WC 9.6.1
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; }