Need help with disable Coupon Snippet with all products subscription

Anyone know what snippet I could use to disable coupons for subscription products only with all products with subscription plugin? The snippet I’m using now disables all coupons if there is a subscription product in the cart. I need it disable the subscription product only and still have it apply to the one time purchase products in the cart. It’s creating an inconvenience to my customers because they have to make the purchase with a coupon separately. Thanks in advance. This is what I’m using now.

add_filter( 'woocommerce_coupon_is_valid', 'disable_coupons_for_subscription_products', 10, 3 );
function disable_coupons_for_subscription_products( $is_valid, $coupon, $discount ){
    // Loop through cart items
    foreach ( WC()->cart->get_cart() as $cart_item ) {
        // Check for subscription products using "All products for subscription" add on
        if ( isset($cart_item['wcsatt_data']['active_subscription_scheme']) 
        && ! empty($cart_item['wcsatt_data']['active_subscription_scheme']) ) {
            $is_valid = false; // Subscription product found: Make coupons "not valid"
            break; // Stop and exit from the loop
        }
    }
    return $is_valid;
}

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.