Show customers their points balance in your storefront using Shopify customer metafields.
Enable publication
- Open NASP Rewards in Shopify Admin.
- Choose Settings, then Storefront data.
- Choose Enable.
At the moment, we publish the following data to metafields:
- Points balance
- Birthday
To stop publication, choose Disable on the same page.
Read the metafields
Customer metafields use the merchant-owned namespace nasp_rewards:
customer.metafields.nasp_rewards.points_balance.valueis the signed-in customer’s points balance.customer.metafields.nasp_rewards.points_birthday.valueis the customer’s optional recorded birthday.
Display a signed-in customer’s points
Add this Liquid to your theme to display a signed-in customer’s points balance.
{% if customer %}
{% assign points_balance = customer.metafields.nasp_rewards.points_balance.value %}
{% if points_balance != nil %}
<p>{{ points_balance | escape }} points</p>
{% endif %}
{% endif %}
Test your display with a signed-in customer, a signed-out visitor, a zero balance, and an unavailable metafield. Keep birthday optional. Its absence does not make the points balance unavailable.
For a theme that needs public reward rules or shopper actions, see the storefront loyalty API.