Add a free gift card to my order via Shopify FLOW

Solved

Add a free gift card to my order via Shopify FLOW

doulmi
Shopify Partner
10 0 2

Hi there,

 

I'm trying to automatically add a gift card to my orders using Flow, and I want it to be added for free without increasing the order total. I've tried two methods:

 

- Using "add order line" and then marking the order as paid. This automatically sends the gift card to the customer, but it changes the order total amount by adding the gift card's value.

 

- Using the officially recommended "Add free (discounted 100%) item to new orders" method. Although this adds the gift card as a free item, it doesn't automatically send the gift card; I have to manually click "send gift" for it to be delivered.

 

I also checked some App, such as rise.ai, but they use another template but not my own gift card email template. 

 

Any help would be greatly appreciated,

 

Thanks

 

Accepted Solution (1)
paul_n
Shopify Staff
1690 185 387

This is an accepted solution.

Try the "Mark as fulfilled" action instead

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 15 (15)

paul_n
Shopify Staff
1690 185 387

It's not possible yet in Flow because to send the gift card you would need to call an API that was introduced in 2024-10 and Flow is currently using 2024-04. Flow's currently working to adopt 2024-07

 

Docs on the new mutations to send the gift card to a customer or the recipient https://shopify.dev/docs/api/admin-graphql/2024-10/objects/GiftCard#mutations

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
doulmi
Shopify Partner
10 0 2

Hi Paul

 

Thanks for your reply. Do you have a rough timeline for when 2024-07 and 2024-10 will be adopted into Flow? I need to determine whether it’s worth creating my own server to call this API first.

paul_n
Shopify Staff
1690 185 387

It has to be done by October. I don't have a solid timeframe as upgrading API versions is currently a high amount of effort and we are working to make it faster.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
doulmi
Shopify Partner
10 0 2
Thank you for your prompt reply😊
doulmi
Shopify Partner
10 0 2

Hi Paul, 

 

I'm currently trying to use `giftCardSendNotificationToRecipient` on my server, but I don't have the gift card ID until it's fulfilled (after clicking the "Send the gift card" button).

Do you know if there's a way to achieve this using giftCardSendNotificationToRecipient, or do I need to use another API to handle the fulfillment?

Thanks

paul_n
Shopify Staff
1690 185 387

I don't think it's true that you don't have the gift card until after fulfillment. If you create the gift card, you should have the ID.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
doulmi
Shopify Partner
10 0 2

Hi Paul,

 

In my workflow, I add a gift card product variant to my order and mark it as free. However, I don't see any new gift card appearing on the gift_cards page in the admin UI, and I can't find the gift card ID in the `order.json` either; only the LineItem is available for it.

 

Could you have any idea where I can find the related gift card ID?

paul_n
Shopify Staff
1690 185 387

I see. There are gift card products and gift cards. You are adding a gift card product to the order, which must then be fulfilled in order to create the gift card. You must have auto-fulfillment turned off?

 

Usually on fulfillment I think it would email the gift card out. Is that what happens when you fulfill from the Admin?

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
doulmi
Shopify Partner
10 0 2

 

Yes, auto-fulfillment is enabled. When I add an order line using the "Add Order Line" action in the flow (which I can't manage to mark as it as free), it is auto-fulfilled. However, when I add a gift card via the Flow Admin API (which I can mark it as free), it is not fulfilled automatcically. I'm stuck at this point.

paul_n
Shopify Staff
1690 185 387

That difference doesn't make sense to me unless the fulfillment logic is taking into account the $0 price of the gift card and not auto-fulfilling because of that. The process we use for the action is basically the same, except that we didn't have the step to discount the line item. 

I think I would focus on fulfilling as part of the same workflow. I think it will send the gift card as part of fulfilling. 

 

Something like this may work:

You might also just be able to use the output of the OrderCommit step. I think it outputs the new Order. 

 

In that case, you could instead:

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
doulmi
Shopify Partner
10 0 2

Thank you so much for your insights! Your explanation really helped me understand the possible issue.

I tried following your solutions, but I encountered a couple of issues:

  1. I'm not sure if the condition I'm using is the same as what you suggested. The final UI looks different on my end (see Image 1).
  2. When I add "submit the fulfillment request", I always get the error message "FulfillmentOrder data not found" (see Image 2). Even when I removed the condition, the error still persists(see Image 2), which is quite strangeWith condition.jpgErrors.jpg.
paul_n
Shopify Staff
1690 185 387

You connected the condition to the wrong port on the "For each" step. You need "do this for each item". 

 

The condition is incorrect. Because you were not in the loop, you did not see the variable for the individual fulfillment order.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
doulmi
Shopify Partner
10 0 2

Thank you for pointing that out. I’ve corrected the issue by connecting the condition to the right port on the "For each" step and using "do this for each item." I’m now able to run the process up to the final step. However, when I try to run the "Submit fulfillment request," I encounter an error:

1740065725197.jpg


I checked and noticed that for gift card order line, the "fulfillment_service" is "gift_card." Could that be causing the issue? I’d appreciate any further advice you might have.

paul_n
Shopify Staff
1690 185 387

This is an accepted solution.

Try the "Mark as fulfilled" action instead

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
doulmi
Shopify Partner
10 0 2

It works ! Thank you so much Paul !