Lantern
Liquid API

wallet

Access customer rewards and store credit balances in a comprehensive JSON object.

Syntax

customer.metafields.lantern.wallet

Description

The wallet metafield contains all available rewards and store credit accounts for the customer in a single JSON object. This includes discount codes, gift cards, product rewards, and store credit balances. The data is automatically updated when rewards are earned, used, or expired.

The wallet metafield contains JSON data that must be parsed using Liquid's parse_json filter before accessing individual properties.

Properties

Type: JSON Object Namespace: lantern

Return Values

ScenarioValueType
Logged in with rewardsFull wallet objectJSON Object
Logged in without rewards{"items": [], "storeCreditAccounts": []}JSON Object
Logged outnullnull

Wallet Structure

The wallet object contains two main arrays:

items Array (Rewards)

Each reward item contains the following properties:

Prop

Type

storeCreditAccounts Array

Each store credit account contains the following properties:

Prop

Type

Examples

Basic Wallet Display

{% assign wallet_data = customer.metafields.lantern.wallet %}
{% if wallet_data %}
  {% assign wallet = wallet_data | parse_json %}

  <!-- Display available rewards -->
  {% if wallet.items.size > 0 %}
    <div class="rewards">
      <h3>Available Rewards ({{ wallet.items.size }})</h3>
      {% for item in wallet.items %}
        <div class="reward-item">
          <span class="reward-type">{{ item.rewardType }}</span>
          {% if item.resourceCode %}
            <code>{{ item.resourceCode }}</code>
          {% endif %}
          {% if item.valueType == 'Percent' %}
            <span>{{ item.value }}% off</span>
          {% else %}
            <span>${{ item.value }} off</span>
          {% endif %}
          {% if item.endsAt %}
            <small>Expires: {{ item.endsAt | date: '%B %d, %Y' }}</small>
          {% endif %}
        </div>
      {% endfor %}
    </div>
  {% endif %}

  <!-- Display store credit -->
  {% if wallet.storeCreditAccounts.size > 0 %}
    <div class="store-credit">
      <h3>Store Credit</h3>
      {% for account in wallet.storeCreditAccounts %}
        <p>${{ account.balance.amount }} {{ account.balance.currencyCode }}</p>
      {% endfor %}
    </div>
  {% endif %}

  <!-- Empty state -->
  {% if wallet.items.size == 0 and wallet.storeCreditAccounts.size == 0 %}
    <p>No rewards available. Keep shopping to earn more!</p>
  {% endif %}
{% endif %}

Wallet Summary Widget

{% assign wallet_data = customer.metafields.lantern.wallet %}
{% if wallet_data %}
  {% assign wallet = wallet_data | parse_json %}
  {% assign reward_count = wallet.items.size %}

  <!-- Calculate total store credit -->
  {% assign total_credit = 0 %}
  {% for account in wallet.storeCreditAccounts %}
    {% assign credit = account.balance.amount | plus: 0 %}
    {% assign total_credit = total_credit | plus: credit %}
  {% endfor %}

  <div class="wallet-summary">
    <h4>Your Wallet</h4>
    {% if reward_count > 0 %}
      <span class="reward-count">
        {{ reward_count }} reward{% unless reward_count == 1 %}s{% endunless %}
      </span>
    {% endif %}
    {% if total_credit > 0 %}
      <span class="credit-balance">
        ${{ total_credit }} store credit
      </span>
    {% endif %}
    {% if reward_count == 0 and total_credit == 0 %}
      <span class="empty-wallet">Earn rewards by shopping!</span>
    {% endif %}
  </div>
{% endif %}

On this page