How can I exclude subscription items from discount function?

Hi Ryoshin,

The issue you’re encountering is a common one in where a single product has multiple variants with different subscription plans or no subscription at all. You want to apply a discount to only one variant of this product, but currently, the discount is applied randomly to any variant of the product.

Unfortunately, Shopify’s discount management system doesn’t provide an out-of-the-box solution for specifying which variant of a product should receive the discount. This is because Shopify considers the product as a whole when applying discounts, not the specific variants.

One possible workaround could be to use the Admin API and scripting capabilities to create a more sophisticated discount logic, eg:

  1. Identify the Subscription Variants: Using the ProductVariant object with the sellingPlanGroupCount field, you can identify the product variants that are associated with a subscription plan. This will let you know which variants should not receive the discount.

  2. Create Custom Logic for Discounts: After identifying the subscription variants, you can create a custom script to apply discounts only to the non-subscription variants of a product. This script can run whenever a customer adds a product to their cart.

  3. Apply the Custom Discount Logic: the script to apply your custom discount logic. This script can be triggered when a product is added to the cart or when the customer checks out.

Would an approach like this work for your use case?