Excluding subscription products on Shopify scripts

SobefyOscar
Shopify Partner
115 11 42

Hi community! I would like to exclude subscription products from being added in the Tiered Discount by Quantity script. 

 

I am checking if the line item contains a selling plan id based on the Shopify scripts API. " This method is useful when the store sells subscriptions and you want the script to detect when a product variant is sold as a subscription. "

 

 # Exclude subscription products
    if line_item.variant.selling_plan_id
      return false
    end

 

 However, the script still fires on subscription products as seen here. It's giving 10% for subscribing and an additional 5% via the script. 

 

Screen Shot 2023-01-17 at 11.32.15 PM.png

Thank you!

Want to customize or make changes to a theme? Hire me.
If my answer was helpful please Like and Accept Solution.
Email: oscar@sobefy.com
Website: Sobefy.com
Replies 3 (3)

chrislind
Shopify Partner
2 0 0

try using a product tag on your subscription item, and excluding that from your discount rule

SobefyOscar
Shopify Partner
115 11 42

Thanks Chris! Our problem is that all of our products can be added as subscriptions. 

Want to customize or make changes to a theme? Hire me.
If my answer was helpful please Like and Accept Solution.
Email: oscar@sobefy.com
Website: Sobefy.com
chrislind
Shopify Partner
2 0 0

I'd experiment with looping through the cart items and their properties and seeing what you can pick off from there. You can do this with the cart  JS API. Good luck!