Use loyalty data in your Shopify Theme

Publish customer balances and birthdays to Shopify metafields for your theme.

Show customers their points balance in your storefront using Shopify customer metafields.

Enable publication

  1. Open NASP Rewards in Shopify Admin.
  2. Choose Settings, then Storefront data.
  3. 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.value is the signed-in customer’s points balance.
  • customer.metafields.nasp_rewards.points_birthday.value is 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.