> For the complete documentation index, see [llms.txt](https://docs.shopwaive.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shopwaive.com/shopify/shopify-flow.md).

# Shopify Flow

With Shopify Flow and Shopwaive create automations when customers place orders, inventory is out of stock, or thousands of other actionable events

## 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 to their balance. The possibilities are endless.

Shopwaive's actions in Shopify Flow are free during the 7-day trial, then need a Shopwaive plan. [Learn more](https://apps.shopify.com/shopwaive)

{% hint style="info" %}
If you have a custom process or request, 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><strong>Shopify store credit</strong></p><p><strong>Shopify Flow Action</strong></p></td><td><p>Add to or take from a customer's Shopify store credit</p><p>This action targets Shopify's native store credit, a separate rail from Shopwaive balances. See <a href="/shopify/shopwaive-balances-vs-shopify-store-credit.md">Shopwaive Balances vs. Shopify Store Credit</a>.</p></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&amp;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><strong>Send email</strong></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&amp;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><strong>Increment balance</strong></p><p><strong>Shopify Flow Action</strong></p></td><td>Add or remove an amount 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&amp;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><strong>Create discount</strong></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&amp;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><strong>Create gift code</strong></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&amp;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><strong>Set balance</strong></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&amp;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><strong>Refund balance</strong></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&amp;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td></td></tr><tr><td><p><strong>Void deposits</strong></p><p><strong>Shopify Flow Action</strong></p></td><td>Provide an order or line item id to void the deposits made for it</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&amp;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td></td></tr><tr><td><p><strong>Earn commission</strong></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&amp;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td><a href="/shopify/referrals-and-affiliates.md">Referrals and Affiliates</a></td></tr><tr><td><p><strong>Create segment</strong></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&amp;token=684e283b-b74c-44f0-8ac1-d6f007571ac3">Shopwaive.png</a></td><td></td></tr><tr><td><p><strong>Send HTTP request</strong></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&amp;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><strong>Shopwaive balance changed</strong></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&amp;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><strong>Shopwaive balance changed by an order</strong></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&amp;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><strong>HTTP POST</strong></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&amp;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>

Use the **Create segment** action to automatically create a customer segment from any Shopify Flow trigger. Just provide a name and query for the segment

## 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. Eleven Shopwaive actions work in Shopify Flow. Choose from the **Increment balance** action to add or remove amounts on a customer's balance, the **Set balance** action to set the balance of a customer's account to a specific value, the [**Create discount**](#create-a-discount-code-and-optionally-send-email) action to create a discount code and optionally send the code in an email to a customer, the [**Create gift code**](#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 [**Send email**](#send-an-email-when-credit-is-deposited) action to send an email with balance to your customer, or the **Create segment** action to create a customer segment when you choose any Shopify Flow trigger, just provide a segment name and query.

Use the [**Void deposits**](#automatic-adjustments-for-order-cancellations-and-refunds) action to void the deposits made for an order after it is cancelled or refunded. Use the [**Refund balance**](#automatic-adjustments-for-order-cancellations-and-refunds) action to refund balance redeemed as a discount code to the customer's digital wallet after an order is cancelled or refunded .

Use the [**Earn commission**](/shopify/referrals-and-affiliates.md) action to automatically deposit commission into affiliate accounts for each order referral. Just connect it to the **Order created** trigger.

Need to trigger your flow when data changes in Shopwaive? See [Triggers](#triggers)

{% hint style="warning" %}
**When an action cannot complete.** The step fails in Flow, with the reason, and later steps do not run. For example, **Set balance** fails with "Invalid balance value, must be greater or equal to 0", and **Create discount** fails when a date cannot be read or Shopify refuses the discount. When a service that Shopwaive needs cannot be reached, Shopify Flow sends the step again later, for up to 36 hours. A step that is sent again changes a balance only once.
{% 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&amp;token=24c7b294-5e65-45de-a09f-4e7e9467b658" alt="" data-size="line"> Send Marketing Email

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 **Create discount** action and Shopify's **Send marketing email** 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.

Did you know? Although the below example describes sending email with Shopify's **Send marketing email** action; You can also design your own email templates using Shopwaive's native email services available in Shopwaive's **Create discount**, **Create gift code**, and **Send email** 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>

<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&amp;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 **Create discount** 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&amp;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 **Create discount** 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

<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&amp;token=8d5615bd-2130-4542-a2de-1bf0462029ab" alt=""><figcaption><p>When the discount is created, Create discount returns its code as <code>{{createDiscount.code}}</code>; use it in any downstream action</p></figcaption></figure>

In Shopify's **Send marketing email** 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).

{% hint style="warning" %}
**Shopify Email cannot read Flow variables.** A Custom Liquid block in Shopify's **Send marketing email** action only sees Shopify Email's own objects (`shop`, `customer`, `all_products`, `abandoned_checkout`, `abandoned_visit`, `email`). It does **not** receive `{{createDiscount.code}}` or any other value from an earlier Flow step, so that variable renders blank there. Two things work:

* **Compute the same code on both sides** (this example): give the Create discount action an explicit **Discount code** built from data Shopify Email also has, then print the *equivalent* expression in the Custom Liquid block. The two sides name the data differently, because Flow sees the trigger's objects and Shopify Email sees only its `customer` object. After an order: Flow `THANKYOU-{{ order.name | remove: "#" }}`, email `THANKYOU-{{ customer.last_order.name | remove: "#" }}` (the example below). For a birthday or segment flow with no order: Flow `BDAY{{ 'now' | date: '%Y' }}-{{ customer.legacyResourceId }}` (Flow's `customer.id` is a `gid://` string; `legacyResourceId` is the number), email `BDAY{{ 'now' | date: '%Y' }}-{{ customer.id }}` (Shopify Email's `customer.id` is that same number).
* **Send the email from Shopwaive** instead: tick **Send email** inside Create discount (use the `{discountcode}` merge tag in the Email Body message) or add Shopwaive's **Send email** action (use `{{createDiscount.code}}`). Both need your sending domain authenticated once in Settings > Email.

If Shopify rejects the discount (for example an **Ends at** value that is not a date), the Create discount step now fails in Flow with the reason and later steps do not run. Use ISO 8601 for dates, for example `2026-10-12T23:59:59Z`, or a Liquid expression that renders to one, such as `{{ 'now' | date: '%s' | plus: 2592000 | date: '%Y-%m-%dT%H:%M:%SZ' }}` (30 days).
{% endhint %}

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&amp;token=2fac38ca-48f1-4a10-bb61-eb42276bdb12" alt=""><figcaption><p>Create a unique discount code and send it with the <strong>Send marketing email</strong> 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.

<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&amp;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 **Send HTTP request** 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 **Send HTTP request** 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 **Order created**

Step 2: Add the **Send HTTP request** action in your Flow, add your payload and header to the request. The example sends a draft order to Shopify's Admin API, so its header value is an Admin API access token from your own custom app. Shopwaive does not provide that token, and a Shopwaive API key does not work with Shopify's API.

<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&amp;token=9f6ef293-a631-475b-ac53-26bf3b26ccb7" alt=""><figcaption></figcaption></figure>

Step 3: Connect the **Send HTTP request** action to the **Run code** 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 **Run code** action to properly extract data from the payload received. Responses from the **Send HTTP request** action are returned as stringified JSON, so you'll need to use JSON.parse() within the **Run code** 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.

<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&amp;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&amp;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.

### Recurring amounts added and removed <a href="#recurring-deposits-and-debits" id="recurring-deposits-and-debits"></a>

{% hint style="info" %}
There are many different workflows and options available. One example provided below explains how to add or remove an amount 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](/shopify/pricing.md) and [features](/shopify/features.md).

Follow these steps to add or remove an amount on a schedule:

**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&amp;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&amp;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&amp;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 fill in either Customer email OR Segment query, 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)

For triggered events such as when an order is created, you can now use the native Shopify Flow **Look up customer in segment** action shown to filter customer deposits based on customer segments

<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&amp;token=523bea49-4267-4694-b331-50c28fb61a50" alt=""><figcaption><p>Look up customer in segment after an order is created to determine if a balance should be deposited</p></figcaption></figure>

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.

Alternatively, leave Customer email blank and instead fill in Segment query with a query like the one shown in the example below that selects only customers who have been tagged

<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&amp;token=6cd1b1de-c27b-435a-9bba-3519ad09ce23" alt=""><figcaption><p>Recurring deposits made easy with Shopwaive</p></figcaption></figure>

For the amount you can choose a static value like 50 in the example above.

For points or rewards on orders, use the loyalty program on the [Loyalty](https://docs.shopwaive.com/shopify/loyalty) page in Shopwaive. It needs no Shopify Flow, and it takes points back by itself when an order is refunded or cancelled.

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

In the example above, you setup recurring **deposits**. You can remove an amount on a schedule with the same flow (just duplicate it), and then for the amount, choose a negative value. See example scenarios below

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

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

Another example provided below explains how to connect a Google Sheet that automatically records the order transaction data when a customer redeems a balance

### 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&amp;token=89238c12-72f3-47cb-8b2d-3098aa5a0a24" alt=""><figcaption><p>Connect a Google Sheet to record Shopwaive order redemptions</p></figcaption></figure>

Shopwaive offers more than one way to redeem a balance. On Shopify Plus, customers can use the **Redeem** button (or switch) in the [Redeem at checkout](/shopify/extensions/redeem.md) block shown during 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&amp;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&amp;token=5fca5116-2934-45a1-9a67-3f74dde145dc" alt=""><figcaption><p>Discount code conditional check to capture orders placed using the Redeem block</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 Spreadsheet URL, Tab name, and Row contents. Your Spreadsheet URL will be a unique URL link found in the Google Sheets app after you create a sheet. Your Tab name 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%2FxoszRIthVehtP1573UUq%2FAddSheet.png?alt=media&amp;token=dd9fa141-3bec-46c4-a7f9-11f476068e11" 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 Row contents, 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&amp;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 Otherwise 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&amp;token=827bf833-544b-452f-bc1f-41c0e390b83f" alt=""><figcaption><p>Check if Order tags include Shopwaive</p></figcaption></figure>

Step 5: Add to the Then route to add this case to the same Spreadsheet setup in **Step 3**

The Spreadsheet URL and Tab name will be the same URL and Tab name connected in **Step 3**.

<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&amp;token=971004be-dc2d-43d2-888e-36b8af9062fc" alt=""><figcaption><p>Add orders tagged with Shopwaive to the Google Sheet</p></figcaption></figure>

For the Row contents, 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.

{% hint style="info" %}
**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 a balance 60 days after deposit <a href="#automatically-expire-credit-60-days-after-deposit" id="automatically-expire-credit-60-days-after-deposit"></a>

With the **Date of expiration** field you can define a static date using the format YYYY-mm-dd, or use liquid to expire the deposit 60 days from the date the deposit posts. The date takes effect when Expiration is on, in **Settings** > **Balances** > **Expiration**. With **Multiple expiry dates** it applies to this deposit only; with **Single expiry date** it becomes the expiry date of the customer's whole balance.

To expire a deposit 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&amp;token=d6388236-c936-4fe7-af88-4cad236ccbd2" alt=""><figcaption><p>Expire a deposit 60 days from the date of deposit</p></figcaption></figure>

### Send an email when a balance is deposited <a href="#send-an-email-when-credit-is-deposited" id="send-an-email-when-credit-is-deposited"></a>

Developers and brand managers can setup a flow to send an automatic email notification when a balance is deposited with Shopwaive's **Send email** Shopify Flow action. In the example below, a customer is sent an email with their new balance after a deposit.

{% hint style="info" %}
Before sending email you will need to enable **Notifications** on the **Email** tab of Settings 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 **Send email** Shopify Flow action

Use the **`{balance}`** 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 **Send email** action with a [HTTP POST](#http-post) trigger to send any custom data to display with liquid variable syntax, for example **{{ available }}** or **{{ transaction }}**.

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

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

### 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 **Order created** 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 **Customer** 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 **Add definition**. In this example, the namespace is equal to **custom** and the key is **referral\_code** 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&amp;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 **SPRING2026**:

<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&amp;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 **Create discount** 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&amp;token=a011f4e7-e345-4290-8096-10bc54ebf3cd" alt=""><figcaption></figcaption></figure>

And after clicking **Add**, we then click the **value**:

<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&amp;token=d6f0f299-a577-4aea-8696-28fd6475f4d6" alt=""><figcaption></figcaption></figure>

And then we see the Liquid code that autofills is equal to **{{order.customer.referralCode.value}}**

<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&amp;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 **Create discount** 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.

<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&amp;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.

**Option 1: (Recommended)** If using the **Create discount** action, you can use the `{{createDiscount.code}}` liquid variable that's created in a downstream **Send email** action. You can check the customer locale to customize language in the **Send email** action. This variable can be used anywhere in the Subject title, Body message, Headline, or Call-to-action to display the discount code. It can also be used anywhere in any action or conditional check, or 3rd party app instance downstream of the **Create discount** 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&amp;token=0e6db472-e1c4-4569-a393-d871d50b2067" alt=""><figcaption><p>In this example, we use the <strong>Send email</strong> action after the <strong>Create discount</strong> 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:** To send the email from the **Create discount** action itself, tick **Send email** and fill **Customer email (recipient)**, **Email Subject title** and **Email Body message**. Use the **`{discountcode}`** merge tag in the **Email Body message** to display the discount code. The tag works in the body only. Note the single curly brackets with no spaces inside them, not to be confused with liquid double curly brackets. The email is sent only when your sending domain is authenticated in **Settings** > **Email**. Without it the discount is still created and the step completes, with no email.

**Option 3:** (Legacy) A template saved with Shopwaive's earlier HTML email editor can still be sent by the **Create discount** action. [Authenticate your DNS records](/shopify/install/setup-branded-email.md), tick **Send email**, enter the template's name in the **Email Template name** field and leave **Email Body message** blank. For a new email, use Option 1 or 2.

(Legacy) A template saved with the earlier HTML editor that uses the discount code [merge tag](https://docs.shopwaive.com/shopify/email-and-campaigns#html-merge-tags) can be referenced in your **Create discount** Shopify Flow action. Keep the merge tag in the template's HTML where you want the code to show. When **Email Template name** is blank, Shopwaive sends its default discount code template.

{% hint style="info" %}
The **Create discount** and **Create gift code** 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&amp;token=c39a57b3-eac7-486e-ae2f-6aca04f29ed3" alt=""><figcaption><p>Example discount code email sent by the Create discount action</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 **Create gift code** 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.

{% 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 and a Shopify Plus subscription. 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. Set **Balance** above 0 and no higher than 2000. Outside that range no gift card is created, and the step fails in Flow with a message. If Shopify does not create the gift card, the step fails in Flow with a message and later steps do not run.
{% 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&amp;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.

**Option 1: (Recommended)** If using the **Create gift code** action, you can use the `{{createGiftCode.code}}` liquid variable that's created in a downstream **Send email** action. You can check the customer locale to customize language in the **Send email** 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 **Create gift code** 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&amp;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&amp;token=37f353dd-124b-4613-a31d-bd7b1cb4319d" alt=""><figcaption><p>In this example, we use the <strong>Send email</strong> action after the <strong>Create gift code</strong> 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:** To send the email from the **Create gift code** action itself, tick **Send Email with Shopwaive** and fill **Customer email (recipient)**, **Email Subject title** and **Email Body message**. Use the **`{giftcardcode}`** merge tag in the **Email Body message** to display the gift code. The tag works in the body only. Note the single curly brackets with no spaces inside them, not to be confused with liquid double curly brackets. The email is sent only when your sending domain is authenticated in **Settings** > **Email**. Without it the gift code is still created and the step completes, with no email.

**Option 3:** (Legacy) A template saved with Shopwaive's earlier HTML email editor can still be sent by the **Create gift code** action. [Authenticate your DNS records](/shopify/install/setup-branded-email.md), tick **Send Email with Shopwaive**, enter the template's name in the **Email template** field and leave **Email Body message** blank. For a new email, use Option 1 or 2.

(Legacy) An example template that uses the gift code merge tags can be referenced in your **Create gift code** Shopify Flow action. For the gift card template, you have the option to include the gift card balance and the redeemable code. In the saved template, 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 balance 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&amp;token=b4d523c7-8759-4cac-8e56-f6414e19d727" alt=""><figcaption><p>Example gift code email sent by the Create gift code action</p></figcaption></figure>

### Automatic Adjustments for Order Cancellations and Refunds

Points that your loyalty program on the Loyalty page pays are taken back by Shopwaive itself when an order is refunded or cancelled: no flow is needed for them. The flows below are for deposits your own flows made, and for balances customers redeemed.

{% hint style="info" %}
Want to restore a balance a customer spent on an order that is refunded or cancelled, or void the deposits made for an order? Use the actions below.
{% endhint %}

Use the **Refund balance** and **Void deposits** 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&amp;token=e2586e9e-af02-44ab-89f6-10187078bf11" alt=""><figcaption><p>Refund balance restores the balance spent on the order, and Void deposits voids the deposits made for it</p></figcaption></figure>

The **Refund balance** action takes the order and restores balance redeemed as a discount code for each Shopify refund on that order. Each refund is restored once, however many times the workflow runs, and never more in total than was redeemed. On an order redeemed as a discount code, the amount restored follows the items and shipping each refund returns: refunding every item and the shipping restores the whole redeemed amount, and a partial refund restores its share. Without this action in a workflow, a Shopify refund does not always restore a redeemed balance. For a balance redeemed as a gift code, the action restores only what each refund puts back on that gift card: when you enter 0.00 for the gift card, as the tip below asks, it restores nothing, so adjust that customer's balance in the Shopwaive app.

If you use the **Redeem** Checkout UI with the Gift Cards Extension on, 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. With 0.00 on the gift card, the **Refund balance** action restores nothing, so put the amount back by adjusting the balance it came from in the Shopwaive app.

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 **Redeem** Checkout UI with the Gift Cards Extension on, you can ignore this tip

<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&amp;token=4a09f08c-7a9d-4382-8b7f-d8d3d726a50b" alt=""><figcaption><p>When using <strong>Redeem</strong> Checkout UI with the Gift Cards Extension on, enter 0.00 for ****SHOP refund amount</p></figcaption></figure>

For voiding deposits, Shopwaive removes the amounts added for the Order ID you provide. Use it with a 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&amp;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&amp;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 trigger</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. A trigger starts your flow when data changes in Shopwaive, for example when your customer's balance changes, and passes the change to your flow. Three Shopwaive triggers work in Shopify Flow.

{% hint style="info" %}
Shopify Flow also lists Shopwaive's loyalty triggers and actions, such as **Adjust loyalty balance**. They are switched off: a workflow built on a loyalty trigger does not start, and a loyalty action stops with a message and changes nothing. Your loyalty program on the [Loyalty](https://docs.shopwaive.com/shopify/loyalty) page needs no flow.
{% endhint %}

Choose from the **HTTP POST** trigger to send a POST request to the Shopwaive **/api/trigger** endpoint to power your Shopify Flow, or the **Shopwaive balance changed** trigger to power your Shopify Flows when a customer's available balance changes and the **Shopwaive balance changed by an order** 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).

#### HTTP POST

When you add the **HTTP POST** 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 **HTTP POST** trigger, and the environment variables that are available are shown with their descriptions if you click the downstream action variable input.

{% hint style="info" %}
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 adding or removing amounts, for example from a CRM or your own backend servers, then you can use the **HTTP POST** 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. Send the POST to `https://app.shopwaive.com/api/trigger` with a Shopwaive API key in the `X-Shopwaive-Access-Token` header and an `Idempotency-Key` header with a new value for each request (the same value again on a retry), as for any other [Shopwaive API](https://api.shopwaive.com) request that changes something. The key needs **Change balances through the REST API (wallets:write)**. Create a key in the Shopwaive API keys card in **Settings** > **Developers** in the Shopwaive app. An old access token stops working. [Read why](https://api.shopwaive.com/api-keys-and-shopify-expiring-tokens). The request's fields and answers are on the [Flow trigger API](https://api.shopwaive.com/reference/rest-api-documentation/flow-trigger-api) page.
{% endhint %}

The **id** 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&amp;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>

#### Shopwaive balance changed <a href="#balance-change" id="balance-change"></a>

Add the **Shopwaive balance changed** trigger to a Flow to power any workflow when your customer's balance changes. No webhook setup or backend code is needed: Flow triggers are the supported way to react to a balance change.

{% hint style="info" %}
Note the key difference in the **Shopwaive balance changed** and **Shopwaive balance changed by an order** trigger is that the latter will include the Order resource associated with the trigger event. Use the **Shopwaive balance changed** 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, budgets created in the app, bulk import operations, etc.)
{% endhint %}

#### Shopwaive balance changed by an order <a href="#balance-changes-from-order" id="balance-changes-from-order"></a>

Add the **Shopwaive balance changed by an order** 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 `previous`, `transaction`, and `available` fields as you do with the **Shopwaive balance changed** trigger, plus the order associated with the event, for example `{{order.id}}`.

Download the [**Shopwaive balance changed by an order**](https://cdn.shopify.com/s/files/1/0651/7650/2517/files/Balance_Updated_By_Order_Trigger.flow?v=1722870393) template or the [**Shopwaive balance changed**](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

## Flow templates

Shopwaive has ready-made workflows for your Shopwaive balance. Open **Shopwaive**, then on Home press **See Flow templates**. Each card says what the workflow does, when it starts and what you choose.

| Template                | Starts when                                      | Then                                                  |
| ----------------------- | ------------------------------------------------ | ----------------------------------------------------- |
| Welcome balance         | A customer is created                            | Adds the amount you choose to their Shopwaive balance |
| Customer tag to balance | A customer gets the shopwaive-bonus tag          | Adds the amount you choose to their Shopwaive balance |
| VIP bonus               | An order is paid by a customer tagged VIP        | Adds the amount you choose to their Shopwaive balance |
| Birthday balance        | A customer joins the birthday segment you choose | Adds the amount you choose to their Shopwaive balance |
| Win-back balance        | A customer joins the segment you choose          | Adds the amount you choose to their Shopwaive balance |
| Low balance reminder    | A purchase leaves a balance above 0 and under 10 | Emails the customer a reminder                        |
| Balance added email     | A customer's Shopwaive balance goes up           | Emails the customer their new balance                 |
| Points earned reminder  | Your loyalty program adds points on an order     | Emails the customer what they earned                  |

### Start a template

1. In Shopwaive, on Home, press **See Flow templates**. The **Flow templates** page opens.
2. On the template you want, press **Build in Flow**. Where Shopify Sidekick is on for your store, Sidekick opens and asks to build that workflow, in the card's own words: check what it builds, fill in what it asks for, then turn it on in Flow. Otherwise Shopify Flow opens a new workflow, and you follow the steps below.
3. Add the trigger the card names under **Starts when**.
4. When the card has **Checks**, add that condition next.
5. Add the step the card names under **Then**: the Shopwaive action, or Send email.
6. Fill in what the card lists under **You choose**, such as the amount or the segment. Nothing is filled in for you, so no balance moves until you choose the amount.
7. Press **Turn on** in Flow.

When a card shows **Open in Flow**, Shopify Flow opens with the workflow ready: fill in what Flow asks for, then press **Turn on**.

{% hint style="info" %}
A workflow runs only after you turn it on, and you can change every step in Shopify Flow. Shopwaive steps in a workflow need a Shopwaive plan. Templates that send an email use Send email, which needs the Checkout plan and your own sending domain. Set this up in Shopwaive under **Settings**, then **Email**.
{% endhint %}

## 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, or funneling triggers to add and remove amounts. Each example on this page links its own template.

{% 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. Contact us anytime at <support@shopwaive.com> for help, we're here and happy to support
{% endhint %}
