less than a minute read • Updated 35 minutes ago
Allow customers to purchase gift cards on your store
How to let customers buy gift cards through your store, with the code sent automatically to a recipient.
You can let customers buy gift cards through your store and have the generated code sent automatically to a recipient they choose.
Enable the gift card for purchase
Set up the recipient notification email
Gift cards purchased through your store need an email template to notify the recipient.
You can use an existing category (including the Default category) or create a new one specifically for gift cards. Whichever category you use, you’ll need to pass it with the add-to-cart request below.
Build the add-to-cart form
Add a form to your website so customers can purchase the gift card. It works like a normal product add-to-cart, with these fields:
name— the name of the productcode— the gift card’s SKU, prefixed withgift_card_(a SKU ofwidgetsbecomesgift_card_widgets)category— the category you set up above; optional only if you’re using the DEFAULT categorygift_recipient_email— the recipient’s email address; must be a valid emailgift_recipient_message— optional; a custom message included in the notification emailprice— the amount to load onto the gift card
<form method="POST" action="https://YOURSTORE.foxycart.com/cart">
<input type="hidden" name="name" value="Widgets Gift Card">
<input type="hidden" name="code" value="gift_card_widgets">
<input type="hidden" name="category" value="your-gift-card-category">
<label>Gift Card Recipient Email:
<input type="text" name="gift_recipient_email">
</label>
<label>Gift Card Recipient Message:
<input type="text" name="gift_recipient_message" value="" placeholder="Enter a custom message for your recipient">
</label>
<label>Gift Card Amount:
<input type="number" name="price" value="10">
</label>
<input type="submit" value="Add Gift Card to Cart">
</form>
Fixed amount vs. customer-specified balance
For a fixed amount, set
priceas a hidden input, or as a set of radio inputs with specific amounts. The customer won’t be able to change it.To let the customer choose their own amount, set
priceas a text input, as in the example above. The customer can enter any value, within any minimum or maximum you set when enabling purchase.
Notes
If a customer tries to add a gift card below the minimum or above the maximum amount, the add-to-cart request fails and an error is shown.