Exclude an app-created gift card product from merchant discount codes (without giftCard: true)

Hi everyone,

We build a gift card app. Our app creates gift card products with productCreate, and when one is purchased, our app issues the gift card itself using giftCardCreate and emails it with our own designs and scheduling.

The problem: because these are regular products, any merchant discount code that applies to “All products” or to the entire order also discounts the gift card. A customer can use a 20% code on a $100 gift card, pay $80, and still receive a $100 card.

What we’ve tried or ruled out:

  • giftCard: true on productCreate. Native gift card products aren’t discountable, but Shopify then issues and emails its own gift card when the product is purchased, on top of ours. The customer ends up with two cards.
  • Collection-scoped discounts. Merchants can limit product discounts to collections that leave out the gift card. But order-level discounts (“Amount off order”) can’t exclude products, and we can’t rely on every merchant setting up their discounts correctly.
  • Discount Function API. As far as we can tell, a Discount Function only controls the discounts it creates itself. It can’t remove or narrow the merchant’s own discount codes on a specific line.
  • Cart & Checkout Validation Function. Our plan is to block checkout when a gift card line’s cost.totalAmount is less than its cost.subtotalAmount. The input has no cart.discountCodes, so we can only detect the effect of a discount, not the code itself. A validation can only block the whole checkout; it can’t remove the discount from just the gift card line. We also found that returning an error on $.cart makes /cart/add.js return 422, so we’ll only return errors on checkout steps (buyerJourney.step).

Questions:

  1. Is there a supported way to mark a product as not eligible for any discount (product-level and order-level) without making it a native gift card product?
  2. Alternatively, is there a way to use giftCard: true but stop Shopify from issuing its own gift card, so our app handles issuance?
  3. In our testing, product-level discounts reduce cart.lines[].cost.totalAmount in the validation input, but order-level (“Amount off order”) discounts don’t. Even at buyerJourney.step: CHECKOUT_INTERACTION, with the discount showing in checkout, every line keeps totalAmount == subtotalAmount. Is there any way for a validation function to see an order-level discount, or its effect on a specific line?
  4. If a cart has a gift card and another product with one discount code, is there any way to keep the discount on the other product while stopping it from applying to the gift card? Or is blocking checkout the only option?

Any pointers or examples would be much appreciated. Thanks!

The Discount Function API allows you to reject discount codes conditionally now, but I’m not sure whether it can block automatic discounts.

Bro, thank you. I just looked into this. This is a big improvement but you’re right it only works for codes it seems. I have only read the docs so far but will test it out. thanks again!

There isn’t a supported way to make a regular product ineligible for all product-level and order-level discounts. For native product discounts, the merchant can target a collection that omits the gift card product. For discounts implemented with a Discount Function, a product discount can omit the gift card line, while an order discount can exclude the gift card line from its discount calculation.

If the concern with giftCard: true is the native gift card notifications being sent, Shopify Plus stores can ask Support to suppress their store-wide delivery by email and SMS.

Note that a Discount Function can reject an entered discount code, but it rejects the code as a whole. It can’t remain applied to other products while being rejected only for the gift card line.

Thanks page. Are there any updates potentially coming that would allow this? Asking a merchant to make every discount they create exclude our gift card is a bit of hack that puts us behind the eight ball and doesnt allow our gift card product to compete against Shopifys option on level playing field I feel.

In your discount function, use the Exclude Product Rules. If a product is defined in an exclusion rule, it should be completely excluded from the discount calculation and should not be considered for any applicable discount rule.

We used it in ur discount app to resolve use case where some specific products were to be ignored when applying discount.

Worth flagging that exclusion logic only applies if the discount itself runs through your Function. A plain native code-based “amount off order” discount still can’t exclude a line item on its own, so this only solves it if you’re also moving that order discount to your own app.