Discount code with One Free Product from collection or group of products

Hello, i’m trying to find a way to generate discount codes for our members with graphql admin api
So discount code should allow customers to get One free product from group of products or collection.
Limitations: usageLimit=1, usesPerOrderLimit=true

i’ve tried basicCodeDiscount but there is no usesPerOrderLimit
and with discountCodeBxgyCreate - it doesn’t work with customerBuys.items.all = true. So it’s required to specify collection or product which customer have to buy to get free one free product?

Does anyone know how to do it may be in other ways?
may be i’ll try to use auto-discount function with enteredDiscountCodesAccept result, but it’s looks tricky, hope there is another way

I think functions are better suited to solving your particular use case. The documentation is here.

Alternatively, if you’d rather solve this through an app, our app (Dollarlabs: Ultimate Discounts) can help set this up in no time :slightly_smiling_face:

Here’s what a config to give 1 unit of a product free from a collection would look like on the app.

You can set this up as a manual discount and then generate any amount of bulk codes/coupons that follow the same logic and export them as a CSV, and you can also set the Limitations: usageLimit=1, usesPerOrderLimit=true by setting it up in this section of the configuration

Hopefully that gives you either a good starting point - or if you choose to go the app route, a faster time to finish as well :slightly_smiling_face:

Best wishes

Thanks for the response. We are trying to build our own system.
I’m not fully familiar with discount functions yet. We can work with customer metafields inside a function to track if they’ve claimed their gifts, but we have to rely on order webhooks to update these metafields, which can introduce some issues.
For example, while the webhook is still processing, a customer might place another order for the same free product.
This is why we’ve been looking into using the Discount Codes API — because Shopify guarantees one-time usage for discount codes.
In same way Shopify added fetch and external codes support into functions, but how to restrict customer to use it only once - a mystery to me

May be i got sth wrong and you can explain it better, thanks!

1 Like

Artem - seems like you have some familiarity already and you’re on the right track here.

Before I dive into a better approach / even suggest a solution. I’d first like to understand the offer in detail from a customer standpoint. For example if I were to go to your store and buy a product how would the discount / offer look like for me as a customer?

Thank you!

@ArtemFokin , I’m confident you’d have reached a solution already at this point :slightly_smiling_face:

If yes - can you share how you did it so that others can find value from the same ?

Or even mark my answer as a solution if you think others who might not be technically inclined can find value from the same.

Thanks