wc_protected_product_add_to_cart()WC 1.0

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() code WC 8.7.0

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;
}