Initialization
To initialize the Recharge JavaScript SDK, you will need to do it within the root of your theme (wherever the <head>
element is located). Generally this tag is located in a file called theme.liquid
.
Pre-requisites
Before using the SDK, make sure you have configured Rewards for your store. (See Rewards)
Overview
Rewards can be used to incentivize subscription purchases and provide credits to customers for achieving certain milestones such as 3 consecutive subscription charges.
Example
Load the JavaScript SDK script, and then initialize it with your store domain:
<head>
<!-- Rest of your code -->
<script src="https://static.rechargecdn.com/assets/storefront/recharge-client-1.26.0.min.js"></script>
<script>
recharge.init({
// This should be your myshopify.com domain
storeIdentifier: '{{shop.permanent_domain}}',
appName: 'appName',
appVersion: '1.0.0',
});
</script>
</head>
Get the customer's session using one of the SDK Auth
methods, then try some of the example use cases below:
📄️ Get Customer's Credit Balance and Apply to Next Charge
In this example you'll get a customer's credit balance and apply it to their next charge.
📄️ Get Customer's Streak Count and Display It
In this example you'll get the number of consecutive subscription-related charges processed for a customer.
📄️ Determine if Customer's Next Order has a Free Gift
In this example you'll check a customer's upcoming order and check if it contains a free gift.
📄️ Show punch card rewards progress
In this example you'll get the number of consecutive subscription-related charges processed for a customer and display it as progress towards rewards related goals.