The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

automatically generate a gift code?

Hi there,

I want to set up gift products (coffee) where the gift recipient can customize what they get (choose the coffee blend and grind). I think the easiest way will be to set up a Coffee Gift product and then email a gift code that can be used by the recipient to choose their coffee.

Is there a way to automatically generate a gift code? If they are purchasing more than one bag of gift coffee, multiple gift codes would be needed. Can this be done as one "gift product"? For example, one gift product costs $19 for one bag and would generate one code. Another gift product would cost $38 for two bags and would generate two codes...

Or is there an easier / better way to set up customizable gift products?

  • fc_adamfc_adam FoxyCart Team

    Good question. There are a couple ways you could approach this.

    Firstly - you could make use of coupons as you noted. There are two ways you can create a coupon - either manually in the administration or automatically within your code using our new Hypermedia API ( The latter creating a more automated set up but also requiring a more advanced skillset with server-side programming.

    You could create coupons manually in bulk, or as needed with the hAPI and then using our webhook functionality, send the required amount of coupon codes to the customer to use. The customer can then complete a purchase within your store as normal and use the coupons to discount their order. The webhook would be a key aspect here - as it would be need to be able to generate/fetch the coupons and send the gift recipient their codes - they wouldn't be included within the normal order receipt.

    Another approach you could take would be to set up a custom page on your website where gift recipients could go and add the custom coffee to their cart. This would essentially be a sort of custom add to cart page for just them. You could set up a login form of sorts - where the gift recipient would need to enter some information to prove they received a gift. For example that could be the transaction ID and their email address. You could then use our API to look up that transaction and confirm that it exists and that the customer email is the correct one entered.

    If validated, you could then allow the customer to add a special $0 product to their cart, customising it as they need. As you would have accessed the original transaction using the API to authenticate the gift recipient, you would have also been able to see how many gift products they were given. In turn you could display the add to cart form to match - limiting them to the right amount for what they were given.

    Both options would allow customers to purchase their gift products from the store, and both providing varying degrees of difficulty in set up as well.
Sign In or Register to comment.