Re: Create Adhoc Gift card orders

Solved

Create Adhoc Gift card orders

rye_dev_team
Shopify Partner
9 0 1

I have a use case where I want to be able to create gift cards that customers can purchase from me.  The flow goes like so:

  1. Buyer goes to a shop and selects a gift card to purchase
  2. They enter the amount they want on the card
  3. When they submit my backend calls the gift card create endpoint and makes a card with their amount and attaches the order to the gift card created
  4. I send them the code.

What I want to know is how can I associate the gift card created with the purchase the customer made since the gift card doesn't exist as a product on the store until after they have checked out? Is it even possible?

Accepted Solution (1)

Liam
Shopify Staff
2873 312 820

This is an accepted solution.

Hi Rye_dev_team,

 

Creating a gift card through Shopify's API and associating it with a customer's purchase is indeed possible, but it needs to be handled carefully. Here's a potential approach to handle this:

  1. Create a placeholder product: You can create a placeholder product in your Shopify store for the gift card. This product can be selected by the customer and the desired amount entered as a custom note or a custom variant.

  2. Customer purchases the placeholder product: The customer purchases placeholder gift card product in your store, entering the desired amount on the during checkout.

  3. Capture the checkout information: After the customer finishes the checkout process, your backend can capture the checkout information, which includes the order details and the customer's information.

  4. Create the gift card: Using the giftCardCreate mutation, you can create the gift card with the amount specified by the customer in their order.

  5. Associate the gift card with the order and the customer: When creating the gift card, you can include a note or metadata that links the gift card to the order ID and the customer ID.

  6. Send the gift card code to the customer: After the gift card is created, you can then send the gift card code the customer via email or other methods.

Would this approach work for your use case?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 2 (2)

Liam
Shopify Staff
2873 312 820

This is an accepted solution.

Hi Rye_dev_team,

 

Creating a gift card through Shopify's API and associating it with a customer's purchase is indeed possible, but it needs to be handled carefully. Here's a potential approach to handle this:

  1. Create a placeholder product: You can create a placeholder product in your Shopify store for the gift card. This product can be selected by the customer and the desired amount entered as a custom note or a custom variant.

  2. Customer purchases the placeholder product: The customer purchases placeholder gift card product in your store, entering the desired amount on the during checkout.

  3. Capture the checkout information: After the customer finishes the checkout process, your backend can capture the checkout information, which includes the order details and the customer's information.

  4. Create the gift card: Using the giftCardCreate mutation, you can create the gift card with the amount specified by the customer in their order.

  5. Associate the gift card with the order and the customer: When creating the gift card, you can include a note or metadata that links the gift card to the order ID and the customer ID.

  6. Send the gift card code to the customer: After the gift card is created, you can then send the gift card code the customer via email or other methods.

Would this approach work for your use case?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

rye_dev_team
Shopify Partner
9 0 1

Thanks for this, I will give it a try and report back