Allow specific products to be purchase only if a coupon is applied in Woocommerce
问题 I am working on a woocommerce website and I am trying to restrict a product to be purchased only if a coupon is applied for it, so it should not be processed without adding a coupon code. User must enter a coupon code to be able to order this specific product (not on all other products). Any help is appreciated. 回答1: For defined products, the following code will not allow checkout if a coupon is not applied, displaying an error message: add_action( 'woocommerce_check_cart_items', 'mandatory