We tested this flow on Shopify’s Horizon theme. The snippets are examples for you to adapt. NASP Rewards provides support for the API only. Your team maintains the theme code for your client.
1. Choose where to show rewards
Use a test store on the NASP Rewards Plus plan. Choose a page and a section in your theme. Our Horizon example uses /pages/rewards, but the API works from other storefront pages too.
Choose an active points reward and a test shopper who qualifies for it. In this tutorial, a shopper with 550 points chooses a blanket that costs 100 points.
2. Display the shop’s rewards
A guest can browse rewards. Request GET /v1/configuration when your section loads. The loyalty function below is a small example of calling the API with the browser’s fetch. Use your theme’s own request code if you already have it.
const apiRoot = '/apps/nasp-rewards/v1';
async function loyalty(path, options = {}) {
const response = await fetch(apiRoot + path, {
method: options.method ?? 'GET',
headers: options.body
? { Accept: 'application/json', 'Content-Type': 'application/json' }
: { Accept: 'application/json' },
body: options.body ? JSON.stringify(options.body) : undefined
});
if (!response.ok) throw new Error('Rewards request failed: ' + response.status);
return response.json();
}
If the merchant changed the app proxy path, use their path in apiRoot. For the catalogue, the sample uses an empty <ul data-reward-list></ul> in the section. Adapt the selector to your own markup.
const { rewards } = await loyalty('/configuration');
const list = document.querySelector('[data-reward-list]');
for (const reward of rewards.filter(reward => reward.distribution === 'points')) {
const item = document.createElement('li');
item.textContent = reward.title + ' · ' + reward.points_amount + ' points';
list.append(item);
}
You should see the blanket’s name and its standard price of 100 points. If your client offers VIP prices, show the shopper’s tier price once you know their tier. Reward prices and eligibility
3. Show the shopper’s balance
In your theme’s Liquid section, use customer to choose between a sign-in link and a place to show the balance. This example exposes the shopper ID as text for the next step.
{% if customer %}
<p data-shopper-id="{{ customer.id | escape }}">
Points: <span data-points-balance></span>
</p>
{% else %}
<a href="{{ routes.storefront_login_url | escape }}">Sign in to see your points</a>
{% endif %}
Read GET /v1/customer when the shopper is signed in. The response contains their balance in points_balance.
const balance = document.querySelector('[data-points-balance]');
if (balance) {
const customer = await loyalty('/customer');
balance.textContent = customer.points_balance;
}
Open the page as a guest. You should see the rewards and sign-in link. Sign in as the test shopper and return to the page. Our shopper sees Points: 550.