# Shopify Flow

## Getting started

Shopify Flow enables merchants to create powerful workflows triggered by events. For example, when an order is placed, a transaction can be automatically recorded in a connected Google Sheet, or a customer can receive deposits in credit. The possibilities are endless.

{% hint style="info" %}
The Shopwaive Development team is continuously adding new features like Shopify Flow actions and triggers to streamline D2C and B2B workflows on Shopify. If you have a custom process or request you need please contact <support@shopwaive.com>, we're here to help
{% endhint %}

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden></th><th data-hidden data-card-cover data-type="image">Cover image</th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><p><mark style="color:blue;"><strong>Shopify store credit</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>New! Credit or debit customer's with native store credit</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://changelog.shopwaive.com/posts/quickstart-7">https://changelog.shopwaive.com/posts/quickstart-7</a></td></tr><tr><td><p><mark style="color:blue;"><strong>Send email</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Send your customer an email with their balance</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://docs.shopwaive.com/shopify/shopify-flow#send-an-email-when-credit-is-deposited">https://docs.shopwaive.com/shopify/shopify-flow#send-an-email-when-credit-is-deposited</a></td></tr><tr><td><p><mark style="color:blue;"><strong>Increment balance</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Create a deposit or debit for a customer or segment</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://docs.shopwaive.com/shopify/shopify-flow#actions">https://docs.shopwaive.com/shopify/shopify-flow#actions</a></td></tr><tr><td><p><mark style="color:blue;"><strong>Create discount</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Create a discount code and send in an email</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://docs.shopwaive.com/shopify/shopify-flow#create-a-discount-code-and-optionally-send-email">https://docs.shopwaive.com/shopify/shopify-flow#create-a-discount-code-and-optionally-send-email</a></td></tr><tr><td><p><mark style="color:blue;"><strong>Create gift code</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Create a gift code and send in an email</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://docs.shopwaive.com/shopify/shopify-flow#create-a-gift-code-and-optionally-send-email">https://docs.shopwaive.com/shopify/shopify-flow#create-a-gift-code-and-optionally-send-email</a></td></tr><tr><td><p><mark style="color:blue;"><strong>Set balance</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Set your customers balance to predefined value</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://docs.shopwaive.com/shopify/shopify-flow#actions">https://docs.shopwaive.com/shopify/shopify-flow#actions</a></td></tr><tr><td><p><mark style="color:blue;"><strong>Refund balance</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Provide an order id to refund redeemed amount</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td></td></tr><tr><td><p><mark style="color:blue;"><strong>Void deposits</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Provide an order or line item id to reverse earned points</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td></td></tr><tr><td><p><mark style="color:blue;"><strong>Earn Commission</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Affiliates earn commission on orders and signups</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="referrals-and-affiliates">referrals-and-affiliates</a></td></tr><tr><td><p><mark style="color:blue;"><strong>Create segment</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Create a customer segment  when you provide a query</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td></td></tr><tr><td><p><mark style="color:blue;"><strong>Send HTTP request</strong></mark></p><p><strong>Shopify Flow Action</strong></p></td><td>Send HTTP requests, receive response payloads</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://docs.shopwaive.com/shopify/shopify-flow#send-http-requests">https://docs.shopwaive.com/shopify/shopify-flow#send-http-requests</a></td></tr><tr><td><p><mark style="color:blue;"><strong>Balance change</strong></mark></p><p><strong>Shopify Flow Trigger</strong></p></td><td>Triggers when a customer's balance changes</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://docs.shopwaive.com/shopify/shopify-flow#balance-change">https://docs.shopwaive.com/shopify/shopify-flow#balance-change</a></td></tr><tr><td><p><mark style="color:blue;"><strong>Balance change from order</strong></mark></p><p><strong>Shopify Flow Trigger</strong></p></td><td>Triggers when a customer redeems on an order</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://docs.shopwaive.com/shopify/shopify-flow#balance-changes-from-order">https://docs.shopwaive.com/shopify/shopify-flow#balance-changes-from-order</a></td></tr><tr><td><p><mark style="color:blue;"><strong>HTTP POST</strong></mark></p><p><strong>Shopify Flow Trigger</strong></p></td><td>Triggers when a POST is made to /api/trigger</td><td></td><td></td><td><a href="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVpzcoSBA0YLi7lZzBWyE%2FShopwaive.png?alt=media&#x26;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="https://docs.shopwaive.com/shopify/shopify-flow#http-post">https://docs.shopwaive.com/shopify/shopify-flow#http-post</a></td></tr></tbody></table>

{% hint style="info" %}
New! Use the <mark style="color:blue;">**Create segment**</mark> action to automatically create a customer segment from any Shopify Flow trigger. Just provide a name and query for the segment
{% endhint %}

## Actions

In this section we provide several example use-cases with templates that demonstrate Shopwaive Actions you can add to your Shopify Flow. Actions perform a task when your flow is triggered. Shopwaive offers several Actions you can choose from and we're adding more each day. Choose from the <mark style="color:blue;">**Increment**</mark> action to create deposits and debits on a customer's account, the <mark style="color:blue;">**Assign**</mark> action to set the balance of a customer's account to a specific value, the [<mark style="color:blue;">**Create discount**</mark>](#create-a-discount-code-and-optionally-send-email) action to create a discount code and optionally send the code in an email to an individual customer or an entire customer segment, the [<mark style="color:blue;">**Create gift code**</mark>](#create-a-gift-code-and-optionally-send-email) action to create a gift code and optionally send the code in an email to a customer, the [<mark style="color:blue;">**Email**</mark>](#send-an-email-when-credit-is-deposited) action to send an email with balance to your customer, or the <mark style="color:blue;">**Create segment**</mark> action to create a customer segment when you choose any Shopify Flow trigger, just provide a segment name and query.

{% hint style="info" %}
New! Use the [<mark style="color:blue;">**Void deposits**</mark>](#debits-for-order-cancellation-or-refund) action to void earned deposits after an order is cancelled or refunded. Use the [<mark style="color:blue;">**Refund balance**</mark>](#debits-for-order-cancellation-or-refund) action to refund any redeemed balance amount to the customer's digital wallet after an order is cancelled or refunded .
{% endhint %}

{% hint style="info" %}
New! Use the [<mark style="color:blue;">**Earn Commission**</mark>](https://docs.shopwaive.com/shopify/referrals-and-affiliates) action to automatically deposit commission into affiliate accounts for each order referral. Just connect it to the <mark style="color:blue;">**Order created**</mark> trigger.
{% endhint %}

{% hint style="success" %}
Need to trigger your flow when data changes in Shopwaive? See [Triggers](#triggers)
{% endhint %}

### <img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FtqRm6fmx9GzGE8oM4qME%2Fimage.png?alt=media&#x26;token=24c7b294-5e65-45de-a09f-4e7e9467b658" alt="" data-size="line"> Send Marketing Email&#x20;

Use Shopwaive and Shopify Flow to create a unique discount and send to your customer as part of a post-purchase flow using Shopwaive's <mark style="color:blue;">**Create discount**</mark> action and Shopify's <mark style="color:blue;">**Send marketing email**</mark> action. Post-purchase discounts are one of the best ways to keep your customer's coming back. Now with Shopwaive's Shopify Flow actions, you can leverage this powerful retention tool with just a few clicks.

{% hint style="success" %}
Did you know? Although the below example describes sending email with Shopify's <mark style="color:blue;">**Send marketing email**</mark> action; You can also design your own email templates using Shopwaive's native email services avaialble in Shopwaive's <mark style="color:blue;">**Create discount**</mark>, <mark style="color:blue;">**Create Gift code**</mark>, and <mark style="color:blue;">**Send email**</mark> actions in Shopify Flow. With Shopwaive's email services, you can use any Shopify Flow liquid variables to send powerful email automations. Contact our team to learn more at <sales@shopwaive.com>
{% endhint %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FJksmUmd7BmU7JPn9ALar%2FSendMarketingEmail.png?alt=media&#x26;token=d28a7443-6a2c-4ce1-84b6-dca9ddb166e6" alt=""><figcaption><p>An example post-purchase marketing email flow with Shopwaive and Shopify email</p></figcaption></figure>

Within Shopwaive's <mark style="color:blue;">**Create discount**</mark> action, you can define a unique discount code using all the parameters available from the Discount admin.

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FSndOmekvoKTKKL6q6ziV%2FCreateDiscount.png?alt=media&#x26;token=c1629dbf-e048-41d8-94d1-b632ff538d11" alt=""><figcaption><p>Create a unique code and expiration date (i.e. expires in 14 days) using liquid, choose a percentage or fixed amount</p></figcaption></figure>

For any downstream actions in Shopify Flow, the <mark style="color:blue;">**Create discount**</mark> action returns the discount code created and you can reference this code in any 3rd-party Shopify Flow action using this liquid snippet:

```liquid
{{createDiscount.code}}
```

For example, after we create the discount, we can save the discount as a metafield to the customer&#x20;

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FNkVLf3Qmrh1zcJJzCoQi%2FSaveMetafield.png?alt=media&#x26;token=8d5615bd-2130-4542-a2de-1bf0462029ab" alt=""><figcaption><p>Create discount always returns the code created with <mark style="color:blue;"><code>{{createDiscount.code}}</code></mark>, use it in any downstream action</p></figcaption></figure>

In Shopify's <mark style="color:blue;">**Send marketing email**</mark> action, to display a dynamic discount you can choose from the [availble liquid objects found here](https://help.shopify.com/en/manual/promoting-marketing/create-marketing/shopify-email/create-email/custom-liquid).&#x20;

In the example below, a Custom Liquid block is used to display the code. The HTML/Liquid used is:

{% code overflow="wrap" %}

```html
<span style="font-size:20px;font-weight:bold;">THANKYOU-{{customer.last_order.name | remove: "#" }}</span>
```

{% endcode %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FG5G1ULV7bhvSCotQl1xU%2FEmailTemplate.png?alt=media&#x26;token=2fac38ca-48f1-4a10-bb61-eb42276bdb12" alt=""><figcaption><p>Create a unique discount code and send it with the <mark style="color:blue;"><strong>Send email marketing</strong></mark> action as part of a powerful post-purchase automation</p></figcaption></figure>

### Send HTTP requests

Send HTTP requests and receive response payloads all within the Flow environment.&#x20;

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FALpcKHuf4y7HK01fYZ9O%2FSendHTTPRequest.png?alt=media&#x26;token=4ed018e9-f3b0-43cd-829d-2b457c16b851" alt=""><figcaption><p>Send HTTP Requests within Shopify Flow, receive a JSON stringified response</p></figcaption></figure>

With Shopwaive's <mark style="color:blue;">**Send HTTP request**</mark> action, you can make external requests to your endpoints or other 3rd parties, receive a response payload, and define a schema that extracts variables from the response that you can use elsewhere in downstream actions inside Flow.

To get started quickly, import an example <mark style="color:blue;">**Send HTTP request**</mark> Flow [here](https://cdn.shopify.com/s/files/1/0651/7650/2517/files/Send_HTTP_Request.flow?v=1764359742).

Step 1: Choose any trigger that starts the Flow. In our example, we choose <mark style="color:blue;">**Order created**</mark>

Step 2: Add the <mark style="color:blue;">**Send HTTP request**</mark> action in your Flow, add your payload and header to the request

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Fj28yXTFSP07bkwRePoyN%2Fpayload.png?alt=media&#x26;token=9f6ef293-a631-475b-ac53-26bf3b26ccb7" alt=""><figcaption></figcaption></figure>

Step 3: Connect the <mark style="color:blue;">**Send HTTP request**</mark> action to the <mark style="color:blue;">**Run code**</mark> action

Step 4: Use the [example Flow provided above](https://cdn.shopify.com/s/files/1/0651/7650/2517/files/Send_HTTP_Request.flow?v=1764359742) as a reference to fill out the <mark style="color:blue;">**Run code**</mark> action to properly extract data from the payload received. Responses from the <mark style="color:blue;">**Send HTTP request**</mark> action are returned as stringified JSON, so you'll need to use JSON.parse() within the <mark style="color:blue;">**Run code**</mark> action inside the **Write code** block to parse your data into variable schema format. In the example below, we are defining an object schema with arbirtrarily defined fields **`id`**, **`example`**, and **`email`**, but you can define your own. Ensure you use the Define outputs block to correctly define the schema field types.&#x20;

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FjmBkti0ePXNfVzZKjD9v%2FwriteCode.png?alt=media&#x26;token=72f2c280-9f02-4e47-9747-c578a6b2226c" alt=""><figcaption></figcaption></figure>

Step 5: You can now reference your schema as variables such as {{runCode.email}} in downstream Flow actions and conditional blocks

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FZtnD5CLtEqkyfwBa6wpv%2FrunCode.png?alt=media&#x26;token=c9a6a4bb-954c-4c56-b860-f93b1ac72eaa" alt=""><figcaption></figcaption></figure>

If you have any questions, or need support, just reach out to our dev team at <support@shopwaive.com>, we're happy to assist.

### Setup recurring Deposits and Debits

{% hint style="success" %}
There are many different workflows and options available. One example provided below explains how to make deposits or debits on a recurring schedule, i.e. on the 1st day of each month $50 is deposited to all (or only specific) customers in a defined segment
{% endhint %}

Connecting Shopwaive to Shopify Flows assumes you have already installed the app on your store and purchased a subscription plan. Learn more about our [pricing plans](https://www.shopwaive.com/pricing) and [features](https://docs.shopwaive.com/shopify/features).

Follow these steps to create a scheduled and recurring deposit or debit:

**Step 1:** Add the **Scheduled time** trigger, which will activate the flow to run at a scheduled time, and with recurring or repeat options you define

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FVNSzwvXXX9xK7S2U3wm2%2FDeposit_Step1.png?alt=media&#x26;token=d76bea97-8594-44fd-beb7-e0e4b49381fc" alt=""><figcaption><p>For this example, the flow will trigger on the 1st day of each month, beginning on Feb. 1 at 8:00 am EST</p></figcaption></figure>

**Step 2:** Click the **Then** plus icon on the **Schedule time** trigger, select **Action** and then choose the Shopwaive app from the apps listed in the Installed apps section

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Fh9dM3PeNtXxibP93uZjf%2FAddAction.gif?alt=media&#x26;token=95dcbaa4-4ca1-4caa-9fe2-aff3f19d1247" alt=""><figcaption><p>Add an Action to run when the Schedule time triggers the flow</p></figcaption></figure>

**Step 3:** Choose the **Increment balance** action from the Shopwaive actions list

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Fl8T06keVyztd02TCO91w%2FIncBalance.png?alt=media&#x26;token=317a9499-ceb0-470a-933d-d6233b7b7e1e" alt=""><figcaption><p>Add the Increment balance action</p></figcaption></figure>

**Step 4:** Fill in the options available, you can choose an entire customer segment by providing the customer segment query or you can choose a single customer by providing the email. Note that you need to choose between <mark style="color:blue;">customer\_email</mark> OR <mark style="color:blue;">segment\_query</mark>, but not both. Whichever you choose, leave the other input blank. The former selects a single customer while the latter selects a group of customers in a segment (if any exists)

{% hint style="info" %}
New! For triggered events such as when an order is created, you can now use the native Shopify Flow <mark style="color:blue;">**Look up customer in segment**</mark> action shown to filter customer deposits based on customer segments
{% endhint %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Flr8oonKC7ivtRVYmwyMH%2FLookupSegment.png?alt=media&#x26;token=523bea49-4267-4694-b331-50c28fb61a50" alt=""><figcaption><p>Look up customer in segment after an order is created to determine if credit should be deposited</p></figcaption></figure>

{% hint style="info" %}
Variable syntax is supported in Shopify Flows, which means you can use data from an action upstream in the flow like an email address from a draft order that was created **{{draftOrder.email}}** or the shop's contact email address **{{shop.contactEmail}}**, as a few examples.&#x20;
{% endhint %}

{% hint style="success" %}
Alternatively, leave the customer\_email input blank and instead define customer segment query like the one shown in the example below that selects only customers who have been tagged
{% endhint %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FMoSCKpUQeX8arZ6sp9Qq%2FSegment1.png?alt=media&#x26;token=6cd1b1de-c27b-435a-9bba-3519ad09ce23" alt=""><figcaption><p>Recurring deposits made easy with Shopwaive</p></figcaption></figure>

For the <mark style="color:blue;">amount</mark> you can choose a static value like 50 in the example above OR you can use a multiplier.&#x20;

For example, you can create a Cash Back Rewards flow that deposits 20% cash back on each purchase, or for only specific SKUs, variants, or those defined in a specific collection.

An example of this is shown below, when an <mark style="color:blue;">Order created</mark> is set as the trigger, you can choose the **order**.**totalPriceSet.presentmentMoney.amount** when the **order.fullyPaid** is <mark style="color:blue;">**TRUE**</mark> as a dynamic variable for the <mark style="color:blue;">amount</mark>. Then, you can multiply this by any value, for 20% cash back we choose **0.2**.&#x20;

{% hint style="success" %}
Note that if you choose to require the **order.fullyPaid** field to be <mark style="color:blue;">**TRUE**</mark>, that some Orders that require authorization, for example some forms of payment will prevent the Order to be paid at the time the Order is created, because it first goes through an Authorized state. In this case, Orders that have an authorization delay before being updated to paid will not process through the Flow since its only fired when an Order is first created. Therefore you may wish to relax this requirement and proceed with the deposit and instead create a debit if an authorized order with earned credit is later cancelled.&#x20;
{% endhint %}

{% hint style="info" %}
For more information on Shopwaive's Loyalty programs including tips and guidance, see [Cash Back and Loyalty](https://docs.shopwaive.com/shopify/cash-back-and-loyalty)
{% endhint %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FD2DTWn7z93pWMws6G5Vd%2FCashback.png?alt=media&#x26;token=7f221428-fecc-4036-894d-485be768b599" alt=""><figcaption><p>Setup a Cash Back Loyalty and Rewards program with just a few clicks</p></figcaption></figure>

**Step 5:** Select **Apply changes** and then **Turn on workflow** when you are ready to make the flow live

{% hint style="info" %}
In the example above, you setup recurring **deposits**. You can achieve recurring ***debits*** using the same flow (just duplicate it), and then for the <mark style="color:blue;">amount</mark>, choose a negative value. See example scenarios below
{% endhint %}

> ***Example 1***
>
> If a customer has a $0 balance but are included in a debit flow based on the segment query defined, a debit flow would not have any effect as customer balances cannot be negative

> ***Example 2***
>
> Similarly, if a customer has a $20 beginning balance and subject to a -$50 debit flow, then the customer's final balance after the flow is complete would be $0

{% hint style="info" %}
Another example provided below explains how to connect a Google Sheet that automatically records the order transaction data when a customer redeems store credit
{% endhint %}

### Connect Google Sheets

One of our most popular Shopify Flows allows Shopify merchants to easily connect a Google Sheet to record all your customer transaction history. Follow these steps to get setup in just a few short minutes.

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FFD2KlcZvBtGIsN5LDRMm%2FWorkflows.png?alt=media&#x26;token=89238c12-72f3-47cb-8b2d-3098aa5a0a24" alt=""><figcaption><p>Connect a Google Sheet to record Shopwaive order redemptions</p></figcaption></figure>

Shopwaive offers multiple ways to redeem store credit. For example, customers can use the Storefront widget after adding items to their cart to apply store credit and be routed to checkout. Alternatively, Shopify Plus merchants can choose to use the Checkout widget that is shown only during the checkout flow. A 3rd option includes enabling [Checkout extensions](https://docs.shopwaive.com/shopify/checkout-extensions) to allow customers to redeem credit by logging in and entering their email address in the discount code field at checkout.

The workflow we create will account for all of the aforementioned redemption options.

Follow these steps to create the Google Sheet workflow:

**Step 1:** Add the **Order paid** trigger, which will activate the flow to run each time this occurs

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FQmQ2V56Ww0Q5sfo4andi%2FStep1.png?alt=media&#x26;token=00d977b8-9169-4724-abbd-d4d168a977f5" alt=""><figcaption><p>Add the Order paid trigger to run this flow each time an order is paid</p></figcaption></figure>

**Step 2:** Next, add a conditional check to determine a customer checked out with the extension. In this case we check if a discount code was used equal to the customer's email

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2F2tbM5uBKgGiRgx9L9Rjg%2FStep2.png?alt=media&#x26;token=5fca5116-2934-45a1-9a67-3f74dde145dc" alt=""><figcaption><p>Discount code conditional check to capture orders placed using the Checkout extension</p></figcaption></figure>

**Step 3:** If the conditional check in **Step 2** is true. **Then** we **Add row to spreadsheet**. Connect your Google Sheet by entering your <mark style="color:blue;">Spreadsheet URL</mark>, <mark style="color:blue;">Tab name</mark>, and <mark style="color:blue;">Row</mark> <mark style="color:blue;">contents</mark>. Your <mark style="color:blue;">Spreadsheet URL</mark> will be a unique URL link found in the Google Sheets app after you create a sheet. Your <mark style="color:blue;">Tab name</mark> will also be unique, for new sheets this is typically defaulted to Sheet1 but you can name it anything that is convenient.

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Fae562n7CcveeZlfqBLBB%2FAddSheet.png?alt=media&#x26;token=8e6727c9-a9e7-42fc-b110-b45de14474ab" alt=""><figcaption><p>Add a blank spreadsheet using Sheets</p></figcaption></figure>

Create a Sheet by visiting [Google docs](https://sheets.google.com) and click the blank spreadsheet. For the Column headers, add these to your sheet.

| Email | Code | Order Total | Redeemed | Order ID | Date |
| ----- | ---- | ----------- | -------- | -------- | ---- |
|       |      |             |          |          |      |
|       |      |             |          |          |      |
|       |      |             |          |          |      |

For the <mark style="color:blue;">Row contents</mark>, simply copy/paste the Row contents liquid code provided below.

{% code overflow="wrap" %}

```liquid
{{order.customer.email}},{% for discountApplications_item in order.discountApplications %}
  {{discountApplications_item.DiscountCodeApplication.code}}
{% endfor %},{{order.totalPriceSet.presentmentMoney.amount}},{{order.totalDiscountsSet.presentmentMoney.amount}},{{order.id}}, {{order.name}}, {{order.createdAt}}
```

{% endcode %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FL4PSshBodNsF3ugNzsH5%2FStep3.png?alt=media&#x26;token=4c66941b-8e8b-4c2b-b3a7-bbc29c5ce30c" alt=""><figcaption><p>Connect your Google Sheet</p></figcaption></figure>

**Step 4:** Back up to the Check if conditional block, and add to the <mark style="color:blue;">Otherwise</mark> route. If a discount code is not found equal to the order customer email, then we add another Check if conditional block. In this conditional check, we check if the Order tags includes Shopwaive

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FtBhkIN8wDWStsrWWRUap%2FStep4.png?alt=media&#x26;token=827bf833-544b-452f-bc1f-41c0e390b83f" alt=""><figcaption><p>Check if Order tags include Shopwaive</p></figcaption></figure>

Step 5: Add to the <mark style="color:blue;">Then</mark> route to add this case to the same Spreadsheet setup in **Step 3**

The <mark style="color:blue;">Spreadsheet URL</mark> and <mark style="color:blue;">Tab name</mark> will be the same URL and Tab name connected in **Step 3**.&#x20;

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FEVsTVCUL7mGbEvnN4GcA%2FStep5.png?alt=media&#x26;token=971004be-dc2d-43d2-888e-36b8af9062fc" alt=""><figcaption><p>Add orders tagged with Shopwaive to the Google Sheet</p></figcaption></figure>

For the <mark style="color:blue;">Row contents</mark>, simply copy/paste the Row contents liquid code provided below

{% code overflow="wrap" %}

```liquid
{{order.customer.email}},"", {{order.totalPriceSet.shopMoney.amount}},{% for discountApplications_item in order.discountApplications %}
  {{discountApplications_item.value.MoneyV2.amount}}
{% endfor %},{{order.id}}, {{order.name}}, {{order.createdAt}}
```

{% endcode %}

You are done! Now just apply changes and turn on your flow. Place a test order and check to see the Google Sheet populate with the order data.&#x20;

{% hint style="success" %}
**Advanced users:** You can add to this example, including adding other pertinent order transaction data for instance to the Sheet, by editing the Row contents liquid code and adding additional Columns to capture the extra data. Contact our team if you need developer support at <support@shopwaive.com>. We are glad to help
{% endhint %}

### Automatically expire credit 60 days after deposit

With the <mark style="color:blue;">**expirationdate**</mark> field you can define a static date using the format YYYY-mm-dd, or use liquid to expire the credit 60 days from the date the deposit posts.

To expire credit 60 days from the date of deposit, use the following snippet,

```liquid
{%- assign date = 'now' | date: '%s' -%} 
{%- assign days_until_expired = 60 | times: 24 | times: 60 | times: 60 -%} 
{{ date | date: "%s" | plus: days_until_expired | date: "%Y-%m-%d" }}
```

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FFCdOijOA7umcqbfPn1hv%2FExpireCredit.png?alt=media&#x26;token=d6388236-c936-4fe7-af88-4cad236ccbd2" alt=""><figcaption><p>Expire credit 60 days from the date of deposit</p></figcaption></figure>

### Send an email when credit is deposited

Developers and brand managers can setup a flow to send an automatic email notification when credit is deposited with Shopwaive's <mark style="color:blue;">**Send email**</mark> Shopify Flow action. In the example below, customer's  are incentivized when purchasing a specific product or collection item by receiving a cashback credit, and then sent an email of their new balance.

{% hint style="info" %}
Before sending email you will need to enable <mark style="color:blue;">**Notifications**</mark> from <mark style="color:blue;">**Settings**</mark> and verify your branded sending domain following this [guide](https://docs.shopwaive.com/shopify/install/setup-branded-email)
{% endhint %}

[Download example template below](https://storage.googleapis.com/steel-spark-359918.appspot.com/Send%20email%20on%20deposit.flow) for the <mark style="color:blue;">**Send email**</mark> Shopify Flow action

Use the <mark style="color:blue;">**`{balance}`**</mark> merge tag anywhere in the Subject title, Body message, Headline, or Call-to-action to display the customer's balance. Note the single curly brackets and no spaces between the bracket and balance keyword used for the Shopwaive merge tag, not to be confused with liquid double curly brackets. The merge tag should be used previously as typed above.

Alternatively, you can trigger the <mark style="color:blue;">**Send email**</mark> action with a [HTTP POST](#http-post) trigger to send any custom data to display with liquid variable syntax, for example <mark style="color:blue;">**{{ available }}**</mark> or <mark style="color:blue;">**{{ transaction }}**</mark>.

{% hint style="info" %}
Anywhere in the Headline, Body message, or Call-to-action you can style text using HTML markup. For example, you can use plain text like **Redeem** for the Call to action or use an HTML span tag as shown below to make the Call-to-action button font display **bold,** the former plain text option will inherit the global CSS
{% endhint %}

```css
<span style='font-weight:bold;font-size:18px;'>Redeem</span>
```

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FIRZxN1umBApgQG9NiRD4%2FAdidasFlow.png?alt=media&#x26;token=161c4b61-81a8-4496-a52b-4cc6d6ab4600" alt=""><figcaption><p>You can use dynamic liquid variables, Shopwaive merge tags, and HTML markup to design your email</p></figcaption></figure>

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FXjPcCb8eaUJYumiriiUW%2FAdidasResolution.png?alt=media&#x26;token=b2023d2f-2a5d-4f24-afbb-942ace6aa208" alt=""><figcaption><p>Example email automation for CRM credit and Customer resolution</p></figcaption></figure>

### Create a discount code from an existing metafield value

This tutorial will walk you through how to create a discount code at the time of purchase (i.e. we will use the <mark style="color:$primary;">**Order created**</mark> Flow trigger) that is equal to the customer's metafield value for a selected namespace and key. In this example, we defined the metafield as a <mark style="color:$primary;">**Customer**</mark> metafield, but any metafield definition domain (Products, Collections, Shop, etc.) may be used.

(1) First, we should check to ensure we have defined the customer metafield definition. Visit your **Shopify admin** > **Settings** > **Metafields and metaobjects** > **Customers** and click <mark style="color:$primary;">**Add definition**</mark>. In this example, the namespace is equal to <mark style="color:$primary;">**custom**</mark> and the key is <mark style="color:$primary;">**referral\_code**</mark> as shown below:

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FV7Jp77UyHfhVqEIdRIPL%2Fimage.png?alt=media&#x26;token=ce81c412-f77b-4a64-abc6-78ba4bdc842a" alt=""><figcaption></figcaption></figure>

(2) Secondly, we need to confirm that the purchasing customer (the one who is logged in) is assigned to the order and has a defined value for this customer metafield (custom.referral\_code). If the customer is logged in, they will automatically be assigned to the order. This allows us to access their customer metafield values in Flow.

Here is the customer metafield saved and viewable on the customer detail page. In this example, the customer's referral code is equal to <mark style="color:$primary;">**SPRING2026**</mark>:

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Fh2znF1kSf9pqWSJwuIoH%2Fimage.png?alt=media&#x26;token=bbb9793e-9bf9-46b5-9591-bbf82261f007" alt=""><figcaption></figcaption></figure>

(3) And then finally, in Flow, we set the discount code field inside of Shopwaive's <mark style="color:$primary;">**Create discount**</mark> action equal to the liquid variable as shown:

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Fsw1TDygK17j9eQyNhtkx%2Fimage.png?alt=media&#x26;token=a011f4e7-e345-4290-8096-10bc54ebf3cd" alt=""><figcaption></figcaption></figure>

And after clicking <mark style="color:$primary;">**Add**</mark>, we then click the <mark style="color:$primary;">**value**</mark>:

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FbJGAGm69HdHQCd4UfEvo%2Fimage.png?alt=media&#x26;token=d6f0f299-a577-4aea-8696-28fd6475f4d6" alt=""><figcaption></figcaption></figure>

And then we see the Liquid code that autofills is equal to <mark style="color:$primary;">**{{order.customer.referralCode.value}}**</mark>

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FjiRgVtNt7J0NyWSNqq6x%2Fimage.png?alt=media&#x26;token=542addfa-5769-49a1-b326-4937ea72861d" alt=""><figcaption></figcaption></figure>

### Create a discount code and optionally send email

Developers and brand managers can setup a flow to create a discount code and send an automatic email notification with the code and backlink to your site with Shopwaive's <mark style="color:blue;">**Create discount**</mark> Shopify Flow action. In the example below, a discount code is created and sent to the customer when a draft order is created in the Shopify admin. &#x20;

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FJbVVEtC20SHLZIGwWVDq%2FCreateDiscount.png?alt=media&#x26;token=aef546e0-ba8a-4fdf-b26a-adec0717ad6a" alt=""><figcaption><p>Create discount code and send it in a custom designed email template</p></figcaption></figure>

Several options exist for sending the discount code via email.&#x20;

**Option 1: (Recommended)** If using the <mark style="color:blue;">**Create discount**</mark> action, you can use the <mark style="color:$primary;">`{{createDiscount.code}}`</mark>  liquid variable that's created in a downstream <mark style="color:blue;">**Send email**</mark> action. You can check the customer locale to customize language in the <mark style="color:blue;">**Send email**</mark> action. This variable can be used anywhere in the Subject title, Body message, Headline, or Call-to-action to display the customer's gift card code. It can also be used anywhere in any action or conditional check, or 3rd party app instance downstream of the <mark style="color:blue;">**Create discount**</mark> action

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2F7AmvsAASu3lPtpgrdf2R%2FDiscountCodeFlow.png?alt=media&#x26;token=0e6db472-e1c4-4569-a393-d871d50b2067" alt=""><figcaption><p>In this example, we use the <mark style="color:blue;"><strong>Send email</strong></mark> action after the <mark style="color:blue;"><strong>Create discount</strong></mark> action and reference it using Liquid in the Body message</p></figcaption></figure>

You can use HTML inline-styling to make the discount code appear with bold font as shown in the example above. Of course, there's much more you can do with HTML styling using this method.

**Option 2:** If using the <mark style="color:blue;">**Create discount**</mark> action to send email, you can use the <mark style="color:blue;">**`{discountcode}`**</mark> merge tag anywhere in the Subject title, Body message, Headline, or Call-to-action to display the customer's gift card code. Note the single curly brackets and no spaces between the bracket and balance keyword used for the Shopwaive merge tag, not to be confused with liquid double curly brackets.&#x20;

**Option 3:** (Legacy) If using the <mark style="color:blue;">**Create discount**</mark> action to send email. In the app, when you [authenticate your DNS records](https://docs.shopwaive.com/shopify/install/setup-branded-email) and enable Email campaigns you can send email notifications and reference templates that you design in the Shopwaive app to show the discount code to your customer with backlinks to your site that are a pixel-perfect match of your brand. To reference a template, enter the name of the template in the **Email template** field within the <mark style="color:blue;">**Create discount**</mark> action.

(Legacy) An example template that uses the discount code [merge tag](https://docs.shopwaive.com/shopify/email-and-campaigns#html-merge-tags) can be referenced in your <mark style="color:blue;">**Create discount**</mark> Shopify Flow action. You can even send bulk emails to customer segments with the discount created. You can start with the discount code template that can be added once you install the app and open the email editor. The template already includes the discount code merge tag. Then as you make edits to your design just ensure you keep the discount code [merge tag](https://docs.shopwaive.com/shopify/email-and-campaigns#html-merge-tags) in a location in your HTML template you wish to display the code.

{% hint style="info" %}
The <mark style="color:blue;">**Create discount**</mark> and <mark style="color:blue;">**Create gift code**</mark> actions are just a few of the many enterprise-ready solutions offered by Shopwaive in Shopify Flow. Contact us at <support@shopwaive.com> if you have any questions or need help getting setup, we're happy to help.
{% endhint %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FdevY8Nsb7yYnnuNhLDA9%2FDiscountTemplate.png?alt=media&#x26;token=c39a57b3-eac7-486e-ae2f-6aca04f29ed3" alt=""><figcaption><p>Example discount code template that you can design in the Shopwaive app and connect to Flow</p></figcaption></figure>

### Create a gift code and optionally send email

Developers and brand managers can setup a flow to create a gift card code and send an automatic email notification with the code and backlink to your site with Shopwaive's <mark style="color:blue;">**Create gift code**</mark> Shopify Flow action. In the example below, a gift card code is created and sent to the customer when a draft order is created in the Shopify admin. &#x20;

{% hint style="info" %}
Ensure you meet the requirements to use this feature. To use this enterprise feature, you must have an active Shopwaive Checkout subscription plan, a Shopify Plus subscription, and you must enable the [Shopwaive Gift Extension in the app](https://docs.shopwaive.com/shopify/store-credit/checkout-extensions/extend-store-credit-with-gift-codes). If you've never enabled Gift Cards from the Shopify Admin, you must do this first and create a test card from the admin before connecting Shopwaive. Proceeding without these requirements being met will result in no action taken.
{% endhint %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FAAOiHvvMJJlkm5ADbgbt%2FGiftCardFlow.png?alt=media&#x26;token=696d9fd5-761d-4ccb-b7ee-020d9e8765b3" alt=""><figcaption><p>Create gift card code and send it in a custom designed email template</p></figcaption></figure>

Several options exist for sending the gift code via email.&#x20;

**Option 1: (Recommended)** If using the <mark style="color:blue;">**Create gift code**</mark> action, you can use the <mark style="color:$primary;">`{{createGiftCode.code}}`</mark>  liquid variable that's created in a downstream <mark style="color:blue;">**Send email**</mark> action. You can check the customer locale to customize language in the <mark style="color:blue;">**Send email**</mark> action. This variable can be used anywhere in the Subject title, Body message, Headline, or Call-to-action to display the customer's gift card code. It can also be used anywhere in any action or conditional check, or 3rd party app instance downstream of the <mark style="color:blue;">**Create gift code**</mark> action

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Fkznpb46RHxqqxOlj5D5H%2FGiftCodeFlow.png?alt=media&#x26;token=ef019844-5ed5-4787-a208-7461204d9cf9" alt=""><figcaption><p>Once the gift code is created, you can reference it with Liquid downstream in any block</p></figcaption></figure>

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FwMSFYSvPMtBOioANhB3Q%2FSendEmailFlow.png?alt=media&#x26;token=37f353dd-124b-4613-a31d-bd7b1cb4319d" alt=""><figcaption><p>In this example, we use the <mark style="color:blue;"><strong>Send email</strong></mark> action after the <mark style="color:blue;"><strong>Create gift code</strong></mark> action and reference it using Liquid in the Body message</p></figcaption></figure>

You can use HTML inline-styling to make the gift code appear with bold font as shown in the example above. Of course, there's much more you can do with HTML styling using this method.

**Option 2:** If using the <mark style="color:blue;">**Create gift code**</mark> action to send email, you can use the <mark style="color:blue;">**`{giftcardcode}`**</mark> merge tag anywhere in the Subject title, Body message, Headline, or Call-to-action to display the customer's gift card code. Note the single curly brackets and no spaces between the bracket and balance keyword used for the Shopwaive merge tag, not to be confused with liquid double curly brackets.&#x20;

**Option 3:** (Legacy) If using the <mark style="color:blue;">**Create gift code**</mark> action to send email. In the app, when you [authenticate your DNS records](https://docs.shopwaive.com/shopify/install/setup-branded-email) and enable Email campaigns you can send email notifications and reference templates that you design in the Shopwaive app to show the gift card code to your customer with backlinks to your site that are a pixel-perfect match of your brand. To reference a template, enter the name of the template in the **Email template** field within the <mark style="color:blue;">**Create gift code**</mark> action.

(Legacy) An example template that uses the gift code merge tags can be referenced in your <mark style="color:blue;">**Create gift code**</mark> Shopify Flow action. For the gift card template, you have the option to include the gift card balance and the redeemable code. You can start with the gift code template which already includes the necessary code and balance merge tags. You can start with this to design your own, then as you make edits to your design ensure you keep the gift code [merge tag](https://docs.shopwaive.com/shopify/email-and-campaigns#html-merge-tags) in a location in your HTML template you wish to display the gift code and the credit value [merge tag](https://docs.shopwaive.com/shopify/email-and-campaigns#html-merge-tags) in a location in your HTML template you wish to display the initial gift balance. If you wish to not show these dynamic variables, you can simply delete these \<span> tags from your HTML.

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FazL3VFVBT87a8G2FW2ES%2FGiftCode.png?alt=media&#x26;token=b4d523c7-8759-4cac-8e56-f6414e19d727" alt=""><figcaption><p>Example gift code template that you can design in the Shopwaive app and connect to Flow</p></figcaption></figure>

### Automatic Adjustments for Order Cancellations and Refunds

{% hint style="info" %}
Want to automatically remove the earned credit or cash back if an Order is cancelled? Or refund credit spent on an order? No problem. Just follow these steps to implement an Order cancellation or Refund flow.&#x20;
{% endhint %}

You have two options for Order refunds and cancellations.&#x20;

#### Option 1

Explicitly, you can now use the <mark style="color:blue;">**Refund balance**</mark> and/or <mark style="color:blue;">**Void deposits**</mark> actions with Shopify Flow as shown below.

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FvCx2jCsQW7aRT1RY1lXI%2FRefundAndVoid.png?alt=media&#x26;token=e2586e9e-af02-44ab-89f6-10187078bf11" alt=""><figcaption><p>Refund balance spent and Void deposits (i.e. points or cash earnings) created if you use a loyalty program on purchases</p></figcaption></figure>

The <mark style="color:blue;">**Refund balance**</mark> action is provided an order id and will explicitly refund the amount redeemed on an order.&#x20;

{% hint style="success" %}
If you use the <mark style="color:blue;">**Redeem**</mark> Checkout UI with the Gift card extension enabled, a gift code is automatically applied when the customer uses one-click redemption. The gift card redeemed at checkout is automatically disabled when an order is placed and cannot be refunded in the Shopify admin. Instead, enter an amount of 0.00 when processing redeemed gift card Refunds in the Shopify admin. Then, you can use the <mark style="color:blue;">**Refund balance**</mark> action to refund a customer's balance redeemed with a gift code instead of refunding the gift card directly.

If you do not enter 0.00 in the gift card ending with \*\*\*SHOP at the time an order is refunded in the Shopify Admin, you will receive an error and will need to refund a customer's balance manually.

If you do not use the <mark style="color:blue;">**Redeem**</mark> Checkout UI with the Gift card extension enabled, you can ignore this tip
{% endhint %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FIOxQmrBaD1Ex2xGuCM32%2FRefundExtension.png?alt=media&#x26;token=4a09f08c-7a9d-4382-8b7f-d8d3d726a50b" alt=""><figcaption><p>When using <mark style="color:blue;"><strong>Redeem</strong></mark> Checkout UI with the Gift card extension enabled, enter 0.00 for ****SHOP refund amount</p></figcaption></figure>

For voiding deposits, Shopwaive will debit any amount earned on a previous Loyalty program for the Order id provided. This Shopwaive API method voids any earnings or deposits created by order or line item id provided. Use with Refund or Cancellation trigger. If multiple deposits were created on a single order, then all deposits will be voided if only the Order ID is provided. If you prefer to void only deposits created by a specific line item purchased on an order, leave the Order ID field blank and provide the Line Item ID instead

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2F1qZxTkcW1picPQo6K8TB%2FRefundCreatedFlow.png?alt=media&#x26;token=b203be9f-2263-479b-8a9d-092c22de7fd3" alt=""><figcaption><p>Void all order deposits by providing the Order ID, or provide the Line Item ID to void only earnings deposited from a specific Line Item</p></figcaption></figure>

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FCVg7GybZAc1k7pdYpBj2%2FOrderCancelledFlow.png?alt=media&#x26;token=04353ae5-8e8f-4d8e-9789-4f458b6f5096" alt=""><figcaption><p>Similarly, you can use either or both the Void deposits and Refund balance action with the Order cancelled webhook</p></figcaption></figure>

#### Option 2

Implicitly, you can use the Increment balance action in a flow as shown below. The Increment balance action will create a debit, and the amount debited can be a static value or a liquid variable depending on the original order.&#x20;

If an order is cancelled, previously earned cash back may be something you wish to void. We will simply modify the earned credit or cash back flow so that it is triggered by Order cancellation instead of Order created webhook, and then change the increment value to an equivalent negated amount as the original order (original increment amount times -1). An example of the flow is shown below. Or, simply [import the flow template](https://cdn.shopify.com/s/files/1/0651/7650/2517/files/Order_Cancellation_Debit_-_20_Cashback_on_every_purchase.flow?v=1720458551) into the Shopify Flow app.

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FTg2ZI56NPi5oe2iNTIwi%2FOrderCancelled.png?alt=media&#x26;token=1aba6b51-9e0f-40e9-9b4c-e0d49ff2d3f4" alt=""><figcaption><p>Order cancellation that processes a debit in the amount of previous earned cash back</p></figcaption></figure>

## Triggers

In this section we provide example use-cases with templates that demonstrate Shopwaive Triggers you can add to your Shopify Flow. Triggers are powered by subscriptions to webhooks that fire when data changes in Shopwaive. The Shopwaive data-changed event sends a payload to your Shopify Flow that is used to start your flow, when for example, your customer's balance changes. Shopwaive currently offers three triggers, but we're adding more each day.

Choose from the <mark style="color:blue;">**HTTP POST**</mark> trigger to send a POST request to the Shopwaive <mark style="color:blue;">**/api/trigger**</mark> endpoint to power your Shopify Flow, or the <mark style="color:blue;">**Balance change**</mark> trigger to power your Shopify Flows when a customer's available balance changes and the <mark style="color:blue;">**Balance changes from order**</mark> trigger, that fires for the specific event that a customer's available balance changes due to an associated order resource (i.e. when a customer redeems, an order id is attached to the payload sent to your Shopify Flow).&#x20;

#### HTTP POST&#x20;

When you add the <mark style="color:blue;">**HTTP POST**</mark> trigger to a Shopify Flow, send any of the Trigger variables shown in the screenshot below in the request body to the POST /api/trigger endpoint. To view the schema of the request body, just add any action downstream of the <mark style="color:blue;">**HTTP POST**</mark> trigger, and the environment variables that are available are shown with their descriptions if you click the downstream action variable input.&#x20;

{% hint style="success" %}
Although you can make direct POST requests to the [Shopwaive API](https://api.shopwaive.com), if you desire to first send the data to Shopify Flow for conditional checks before making deposits or debits, for example from a CRM or your own backend servers, then you can use the <mark style="color:blue;">**HTTP POST**</mark> trigger to send this data to Flow for processing. You can send a range of Trigger variable types, like generic strings, numbers, or booleans, all of which can be used to determine conditional logic in your downstream Shopify Flow. To setup the POST request, refer to the [Shopwaive API](https://api.shopwaive.com) for including your X-Shopwaive-Access-Token in the Header, as you would do for all other POST requests
{% endhint %}

The <mark style="color:blue;">**id**</mark> field need not be included in the body of the request as it is automatically created by Shopwaive. All fields in the request body are optional, you can use only what you need.

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FQUAVEf1EO9u7WPvE25zJ%2FHTTPPOST.png?alt=media&#x26;token=0fa63368-69a6-4fb4-ad9f-7ce4615fb1d7" alt=""><figcaption><p>Include HTTP POST trigger payload variables in the body of the request to the /api/trigger endpoint to access them in the Shopify Flow environment</p></figcaption></figure>

#### Balance change

Add the <mark style="color:blue;">**Balance change**</mark> trigger to a Flow to power any workflow when your customer's balance changes. When you add this trigger to a Shopify Flow, we make it easy to subscribe to the Shopwaive Webhook services without the hassle of adding the infrastructure to your backend code

{% hint style="info" %}
Note the key difference in the <mark style="color:blue;">**Balance change**</mark> and <mark style="color:blue;">**Balance changes from order**</mark> trigger is that the latter will include the Order resource associated with the trigger event. Use the <mark style="color:blue;">**Balance change**</mark> trigger for all changes to a customer's balance that are unrelated to an Order resource (i.e. adjustments made by an Admin in the app or API, Offers created in the app, bulk import operations, etc.)
{% endhint %}

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FRDCBVSZ3nkyFaN4JcReC%2FBalanceUpdatedTrigger.png?alt=media&#x26;token=5291dc9c-0ca3-4799-bfb3-9d73e7310743" alt=""><figcaption><p>Check customer's balance when it changes to drive actions like deposits or an email notification</p></figcaption></figure>

#### Balance changes from order

Add the <mark style="color:blue;">**Balance changes from order**</mark> to subscribe to balance changes that result from an Order adjustment, like when a customer redeems their balance. Using this special subscription topic, you get the same <mark style="color:blue;">`previous`</mark>, <mark style="color:blue;">`transaction`</mark>, and <mark style="color:blue;">`available`</mark> fields as you do with the <mark style="color:blue;">**Balance changes**</mark> trigger, but also the <mark style="color:blue;">`order_id`</mark> resource that is associated with the event.

Download the [<mark style="color:blue;">**Balance changes from order**</mark>](https://cdn.shopify.com/s/files/1/0651/7650/2517/files/Balance_Updated_By_Order_Trigger.flow?v=1722870393) template or the [<mark style="color:blue;">**Balance change**</mark>](https://cdn.shopify.com/s/files/1/0651/7650/2517/files/Balance_Updated_Trigger.flow?v=1722870393) template, and contact <support@shopwaive.com> if you have any questions using Shopwaive Triggers in Shopify Flow

## Begin your Shopify work flow with a prebuilt template

With Shopwaive and Shopify Flows, you can create powerful automations that connect apps and work flows that power your business. Contact us to receive our support importing or creating your work flow with specific or detailed criteria, aspects of your loyalty program, funneling triggers to power deposits and debits, or redemption and earn requirements. This is one reason of many why brands are switching to Shopwaive; we provide custom white-glove service to create a Rewards and Loyalty program that you define and we bring to life. We've included a link to some successful flows we've prebuilt that you can use as a template and build on to.

[Click here to download](https://storage.googleapis.com/steel-spark-359918.appspot.com/Shopify%20Flows%20Shopwaive.zip) a selection of Shopwaive work flows to use as a starting template or to reuse popular liquid snippets

{% hint style="info" %}
You know your customers better than any other software or platform, thats why with Shopwaive we give the control back to you. You leverage our expertise to implement the program in just days, not weeks or months. Contact us anytime at <support@shopwaive.com> for help, we're here and happy to support
{% endhint %}
