Automatically issue digital gift card post purchase of a certain size of shoe

Hello, I have a store that sells shoes with variants as sizes (e.g., 22, 23 etc) and I have included an option of “Not Sure” size variant for customers that aren’t sure of the footwear size. Once the customer purchases the “Not Sure” size, I would fulfill the order by sending them a physical sizing kit and at the same time, send them a digital copy of a gift card.

I’m looking to set up a shopify workflow that automatically sends a gift card to customers that is the same amount based on what is charged for the “Not Sure” size option. Subsequently, the customer could use the gift card to purchase a pair of the footwear once they have determined the size.

Appreciate any form of assistance on this, thank you!

1 Like

Hi @SFW ,

You can set up this Shopify workflow by using Shopify Flow (if on Shopify Plus) or an automation app like Shopify Flow or Mechanic. First, create a condition in the workflow to check if the order contains the variant labeled “Not Sure.” Once that condition is met, trigger an action to generate a gift card for the same amount as the product price (you can use the order line item value). The gift card can then be emailed automatically to the customer using the same workflow. This lets the customer use the gift card later to purchase the correct size after using the sizing kit. If you’re not on Shopify Plus, you may need a third-party app like Mechanic to generate and email the gift card based on specific order conditions.

Thanks!

Great idea.

I would start with something like this:

(had to rename Flow export to .CSV to attach it here)

1 Like

Hello Tim,

Thank you for taking time to look through this, appreciate it. This looks really promising. I’ve managed to duplicate the workflow. Just have a quick question regarding the invoice.

a. For the last action: Send order invoice, would that contain the details of the gift card?

b. Also, for the last action, how do I send it to the email of the person who purchased it. Do i include {{order.email}} field in the recipient email address? Thank you!

Yeah, since Flow does not have general email action I’ve selected the Send Invoice which looked most promising to me. Maybe use something else

.

Here is the screenshot of the action params I had in my flow:

This line – Gift card Code: {{sendAdminApiRequest.giftCardCode}} – supposed to include the gift card code.

It’s not tested at all, so you’d need to run some …

1 Like

Hi Tim,

Thank you for the detailed instructions! I’ve replicated your flow but am unable to receive the invoice with the gift card. Here’s a screenshot of the variant that is “Not Sure” in my product page. Would you happen to know what else I am missing out? Thank you.

Flow gives you a helpful trace of the flow runs, so you may see where it did not do as expected.

Otherwise – only guesses:

Possible cause – condition matching is case-sensitive – I have “Not sure” in my flow, you have “Not Sure” as product option value.

If no flow runs – maybe you have not activated it, or the trigger did not fire (my flow had “Order paid” trigger, not sure how you test it);

could be other reasons.

If you can expand the trace and share a screenshot, I’d have more info.

Ok sure, I did use “Not Sure” which matches the size variant.

Would this be the portion of the trace that failed?

Yes, I guess so. So this one is obviously run for a different product/variant and it worked as we wanted for that one.

So you need to find a flow run for the order you (or somebody else) made against the “Not Sure” variant and see the trace for that one.

1 Like

Hi Tim,

I was able to locate the product variant field - using product variant title.

However, the flow is able to work up until the last step - send order invoice where the issue lies with a missing order id

Would you happen to know how to resolve this? Many thanks! :slightly_smiling_face:

I know now :slightly_smiling_face:

Problem here is that the “send invoice” action pulls order not from the original trigger, but from the newly created Gift Card – it has an order field and Flow automatically selects this one for the next action. I have not found a way to override this.

( @paul_n – do you know if it’s possible to select which object to use for an action? )

As a workaround we can try to reorder out actions – Send order invoice with Gift card code first and create Gift card via API afterwards.

Potentially, we can generate code for Gift card ourselves and supply it, like this:

{
  "input": {
    "initialValue": "{{lineItemsForeachitem.variant.price}}",
    "customerId": "{{order.customer.id}}",
    "note": "Not Sure variant purchase compensation for order {{order.name}}",
    "code": "{{ lineItemsForeachitem.id | split:"/" | last }}sure"
  }
}

Also, working with Gift cards can be difficult – they are protected. For example, once you’ve created a Gift card you can no longer retrieve it’s code, only last 4 characters are returned, so some workarounds I’ve considered did not work. The code is also limited to 20 characters and allows only a-z0-9…
I’d consider using Discounts instead, also Discounts can be tied to both Customer and product to secure it.

UPDATE: “send invoice” would not work like this, however, you do not need to send e-mail yourself – the system will send e-mail automatically as soon as you create a Gift card.

So you just need to create the gift card and it’s done:

It would be possible to customize the e-mail in Gift card template in Settings=> Notifications.

1 Like

Not possible to override it currently. You can instead use Send Admin API request to call the API directly. In that action you can specify your own order id

1 Like

Ok, that’s what I thought.

It’s just it not always makes the best judgement, while in conditionals you can choose your variables.

Say, in this flow (order created => loop over line items=> create gift card via API if applicable) if I want to, say, put Gift card code into customer metafield it gives me totally unexpected
sendAdminApiRequest.giftCard.order.purchasingEntity.PurchasingCompany.location.company.mainContact.customer.id instead of order.customer.id or, say sendAdminApiRequest.giftCard.customer.id …

Thanks for being here, by the way!

Thanks Tim once again for the detailed advice. As an alternative to gift cards, how would the discount code work in shopify flow? Specifically in this case, how would a 100% discount code based on the product variant’s price work? Appreciate any form of assistance, thank you!

Well, Gift card flow turned out to work just fine in my test store; I guess the benefit of automatic e-mail sending is crucial here.

Yes, discount can work as well, but would need an app to send e-mail, as “send invoice” does not work as I wanted…

Hi Tim, yeah the gift card flow is working well now. However, I can’t seem to customise my gift card notification email.

Would you happen to know how I could show a customised message - “Thank you for your purchase, kindly use this gift card to offset your purchase once you have determined the size”. - in the gift card notification email. I’ve tried to include a note (Not Sure size) in the gift card API creation step and at the same time, inserted the following liquid code into the new gift card email template, but it doesn’t seem to be working. Appreciate any form of help, thank you!

{% if gift_card.note contains “Not Sure” %}

Thank you for your purchase! Kindly use this gift card to offset your purchase once you've used the sizing kit to confirm the child's size.

{% endif %}

Gift note is not available in Liquid https://shopify.dev/docs/api/liquid/objects/gift_card

Kinda Admin-only field.

And looks like this API does not allow to add a “message” field which would’ve been shown automatically…

If you supply code parameter as part of your action input JSON, same way I’ve suggested in this post then you can use condition like this:

{% if gift_card.last_four_characters == "sure" %}
  

    ...
  

{% endif %}

Another (probably a better one) option is to supply a template_suffix to these gift cards in JSON, like so:

{
  "input": {
    "initialValue": "{{lineItemsForeachitem.variant.price}}",
    "customerId": "{{order.customer.id}}",
    "note": "Not Sure variant purchase compensation for order {{order.name}}",
    "code": "{{ lineItemsForeachitem.id | split:"/" | last }}sure",
    "templateSuffix": "not-sure"
  }
}

And use condition like:

{% if gift_card.template_suffix == "not-sure" %}
  

    ...
  

{% endif %}
2 Likes

Hi Tim,

This is amazing, after spending hours troubleshooting and waiting for shopify help to get back, it finally worked! Thanks much for your advice and help, really appreciate it.