# Cash Back and Loyalty

{% hint style="success" %}
There are many different workflows and options available, in the example below we walk through setting up a Cash Back Loyalty program. For more automations you can achieve and other helpful tips see [Shopify Flows](https://docs.shopwaive.com/shopify/shopify-flow) or [download examples](https://storage.googleapis.com/steel-spark-359918.appspot.com/Shopify%20Flows%20Shopwaive.zip) of our Shopify Flows
{% endhint %}

{% hint style="info" %}
For a more advanced Loyalty program that incorporates more complexity with tiered, paid, or earned membership, [download these Shopify Flow templates to get started](https://cdn.shopify.com/s/files/1/0651/7650/2517/files/Loyalty_ba7afebc-e0f4-41c2-b58c-9e4921814522.zip?v=1728661763). The Loyalty program templates use Shopify Flow that automates updates to metafield definitions, customer segments, and tags to create monthly recurring deposits, earned cash back deposits, Welcome deposits, Birthday deposits, and Loyalty program anniversary deposits. Please contact <support@shopwaive.com>, we're glad to setup a custom advanced loyalty program that meets your precise business requirements
{% endhint %}

## Getting started

Cash Back and Loyalty programs are made easy with Shopwaive's integration with Shopify Flows. Trigger deposits when Orders are placed, on a recurring cycle, and much more. Shopify Flows allows merchants to unlock powerful workflows that are triggered by events, such as when an order is placed customers receive a cash back, discount incentive, or reward

## Create a Cash Back program

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).

{% hint style="info" %}
For this example, we will 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. You can even set a minimum purchase requirement
{% endhint %}

Follow these steps to create a Cash Back Loyalty program:

**Step 1:** Add the **Order created** trigger, which will activate the flow to run when an order is created

<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>For this example, the flow will trigger when an order is created</p></figcaption></figure>

**Step 2:** Click the **Then** plus icon on the **Order created** trigger, select **Condition**, select **If all conditions are met** from the dropdown, and then choose **Add criteria**

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FhIyX88dBV5hMBV7zQjN3%2FThenCondition.png?alt=media&#x26;token=845c8e78-a69a-4bf4-ad22-18651506c551" alt=""><figcaption><p>Choose Then <strong>Condition</strong> for the <strong>Order created</strong></p></figcaption></figure>

**Step 3:** Choose **Order**, and then **fullyPaid**

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FUy1FF3UkdLqCilsAysLT%2FFullPaid.png?alt=media&#x26;token=947fe9be-98c0-48e0-a2af-407ff742e954" alt=""><figcaption><p>Choose <strong>Order</strong> and <strong>fullyPaid</strong></p></figcaption></figure>

**Step 4:** Select **Equal to** and **True**

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Fe2IyVO5TeM78Mz0OpF77%2FTrue.png?alt=media&#x26;token=b7e31bd8-df5f-4708-9014-821a201eab0b" alt=""><figcaption><p>Select <strong>Equal to</strong> and <strong>True</strong> for the order.fullyPaid attribute</p></figcaption></figure>

**Step 5:** Select **Then** and choose **Action** then select the **Shopwaive** app

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2Fn6lQGPKzkUyJdaZ4IS1Q%2FCashback.gif?alt=media&#x26;token=c7124ed3-306a-437a-a176-52f15ac5f3fd" alt=""><figcaption><p>If the condition is True, select a Shopwaive action to run</p></figcaption></figure>

**Step 6:** Choose the **Increment balance** action from the Shopwaive actions list. Next you'll select **Add a variable** to the <mark style="color:blue;">amount</mark> input field.&#x20;

An example of this is shown below, when an <mark style="color:blue;">Order created</mark> is set as the trigger, you can optionally choose the **order**.**totalPriceSet.presentmentMoney.amount** as a dynamic variable for the <mark style="color:blue;">amount</mark>. Then, you can choose a multiplier to multiply this by any value, for 20% cash back on every purchase we choose **0.2**. You can add any note when this transaction occurs, your customers can view this in their transaction history after logging into their account.

{% hint style="info" %}
If you choose to add the **order.fullyPaid** is <mark style="color:blue;">**TRUE**</mark> condition, keep in mind some orders may first go through an Authorized state before being promoted to fully paid status. To capture these delayed paid orders, be sure to not include the order.fullyPaid condition in your work flow
{% 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>Add the Increment balance action</p></figcaption></figure>

**Step 7:** Next, choose your audience for the 20% Cash Back program. You can choose an entire customer segment by providing the customer <mark style="color:blue;">segment\_query</mark> 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). In this example, we chose to limit the 20% Cash Back program to only customers that are tagged with **FALL2023**.&#x20;

{% hint style="success" %}
If you choose to use the segment\_query, ensure you follow the same query syntax you use to define Customer segments in the Shopify Admin, for example **customer\_tags CONTAINS 'FALL2023'**. Note that in this query definition the tag is enclosed with single quotes
{% endhint %}

{% 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
{% endhint %}

You are done! Now select **Apply changes** and **Turn on your flow**. Place a test order and check to see your Cash Back rewards are deposited.

## Debits for Order cancellation <a href="#debits-for-order-cancellation" id="debits-for-order-cancellation"></a>

{% hint style="info" %}
Want to automatically remove the earned credit or cash back if an Order is cancelled? No problem. You now have two options. Use the new [<mark style="color:blue;">**Void deposits**</mark>](https://docs.shopwaive.com/shopify/shopify-flow) and [<mark style="color:blue;">**Refund balance**</mark>](https://docs.shopwaive.com/shopify/shopify-flow) actions on Shopify Flow, or follow the steps below to implement a basic Order cancellation flow.
{% endhint %}

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://docs.shopwaive.com/~gitbook/image?url=https%3A%2F%2F1743155819-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6HSAZj4RDucpQwVtzMYt%252Fuploads%252FTg2ZI56NPi5oe2iNTIwi%252FOrderCancelled.png%3Falt%3Dmedia%26token%3D1aba6b51-9e0f-40e9-9b4c-e0d49ff2d3f4&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=96ecc71b&#x26;sv=1" alt=""><figcaption><p>Order cancellation that processes a debit in the amount of previous earned cash back</p></figcaption></figure>

**For Overachievers:** This next step is only for the overachievers that need to earn that "extra credit" 🎉

Further constrain your Cash Back program to only make 20% cash back deposits on every purchase **IF** the minimum purchase amount is met. Simply click the **Condition** block created in **Step 2** above, and were just going to add another criteria **order.subtotalPriceSet.presentmentMoney.amount** is **Greater than 100**. Now, only orders with subtotals that are greater than $100 will trigger the Cash Back deposit. Depending on your Cash Back program preference, you can choose totals using **totalPriceSet** instead of **subtotalPriceSet**

<figure><img src="https://1743155819-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6HSAZj4RDucpQwVtzMYt%2Fuploads%2FZ2ApLucovXQJRp2YlIk1%2FMinimumPurchase.png?alt=media&#x26;token=9b56e3c2-0bd2-40bb-b1cd-d09d3bb313b2" alt=""><figcaption><p>Minimum order for 20% Cash Back program</p></figcaption></figure>
