Applying discounts in Shopify
In this tutorial, we'll show you how to apply discounts at checkout using Shopify and Talon.One.
Let's imagine you want to create a 20% discount in Shopify that applies to all orders over $100 in your store. You can do this by creating a discount function in Shopify and a rule in Talon.One. When a customer checks out, the discount is applied to their order.
Talon.One requirements
- You are an Admin user.
- You have set up an Application.
- You have created a campaign.
- (To discount individual items) You have created a cart item catalog and connected it to your Application.
Shopify requirements
- For the discount feature to work, network access for Shopify Functions must be enabled. This is available with Shopify for enterprise.
- Discounts are applied via the Storefront API using the
@defer
directive. If a store uses the Ajax API to manage the cart, discounts won't be visible until the customer reaches checkout.
- You are an Administrator user.
- You have completed the basic setup of the Talon.One Shopify app.
- (To discount individual items) You have synced the cart item catalog with your product inventory in Shopify.
Setting up the integration
Configure your Shopify store
Modify the template of your store so that on every cart update, the store calls the Create or update customer session endpoint of the Shopify Integration API.
The call must include the Shopify cart ID, which is used as the customer session ID in Talon.One, and a list of line items in the Shopify cart.
If you use Hydrogen, this involves modifying components in the /app/routes
directory,
specifically in the cart.jsx
file. These components are responsible for fetching the data required for a specific page.
For more information, see the Hydrogen documentation
and a code sample on GitHub.
If you need further help, contact your Customer Success Manager.
Create the discount function in Shopify
Create a discount function to enable the data flow between Shopify and Talon.One. We recommend using only one discount function for all Talon.One discounts in your store.
- In Shopify, open Discounts.
- Click Create a discount.
- In the Talon.One section, select Talon.One discounts.
- Configure the discount function:
- Discount title: Type a descriptive title, such as
Talon.One discounts
. - (Optional) Start and end dates: Ensure the start date aligns with your launch or testing needs, and leave the end date disabled.
note
These dates determine when Talon.One is contacted for discounts, not when individual discounts become active. To schedule discounts, use Talon.One's features, for example, campaign scheduling or coupon scheduling.
- Discount applies to: Select which type of discounts you want to use with Talon.One (product, order, or shipping discounts). If you are unsure, select all three options.
- Discount title: Type a descriptive title, such as
- Click Create discount.
The Discounts page now shows the discount function you created.
Create an additional cost
To allow shipping discounts, create an additional cost in Talon.One with the following properties:
- Scope: Cart (Session)
- API name:
shipping
Create a rule in Talon.One
-
Open a campaign in the Application that is connected to your Shopify store.
-
Depending on where you want to apply the discount, do one of the following:
- To create an order discount, create a rule with the Discount session total effect.
- To create a product discount, create a rule with the Discount individual items effect.
- To create a shipping discount, create a rule with the Discount additional cost effect.
note- The title of the rule will be used as the discount title in Shopify.
- Currently, the Talon.One app for Shopify allows you to apply up to one discount to each order, product, and shipping cost. Unlimited discounts per category is a feature planned for a future release.
For this tutorial, we'll create a rule that applies a 20% discount to orders over $100:
What Name Properties Conditions Check attribute value - Cart Items Total (Current Session) is greater than
100
Effects Discount session total - Discount name:
20% off
- Discount value: [Session.Total]
* 20%
-
Save the rule.
-
Activate the campaign.
Test the integration
- Add a product to your cart in Shopify and ensure that the cart total is over $100.
- Proceed to checkout.
- Verify that the discount is applied to your order.