This example uses the rewards page request function. On your test store, activate a 25-point welcome gift.
NASP Rewards awards the welcome gift automatically when a new customer signs in for the first time. The customer does not need to claim it manually. Show the gift as information on the page.
Find the offer
Read the earning rules from Configuration. Guests see the same catalogue, so the message can encourage them to create an account.
const { earning_rules } = await loyalty('/configuration');
const gift = earning_rules.find(rule => rule.activity === 'welcome_gift');
If there is no welcome_gift row, the shop isn’t offering one.
Describe the reward
benefit describes the default reward. Its type is points, amount_off_order or free_product, or none when the shop sets no default.
function describe(benefit) {
switch (benefit.type) {
case 'points': return `${benefit.points} points`;
case 'amount_off_order': return `${benefit.percentage}% off your order`;
case 'free_product': return `a free ${benefit.product_title}`;
}
}
if (gift && !gift.paused && gift.benefit.type !== 'none') {
document.querySelector('[data-welcome]').textContent =
`Create an account and get ${describe(gift.benefit)} when you first sign in.`;
}
In our example, the page reads Create an account and get 25 points when you first sign in. Points appear in the customer’s points history. A discount or free product arrives as a single-use code in their rewards.
VIP tiers
A new customer receives the reward for their VIP tier when the gift is given, usually the entry tier. tier_benefits lists each tier’s mode (default, custom or none) and resolved benefit. When paused is true, the shop’s VIP programme is paused and new customers don’t receive this gift, so hide the message. Configuration reference