Liquid API
referral_code
Access the customer's unique referral tracking code for sharing with friends.
Syntax
customer.metafields.lantern.referral_codeDescription
The referral_code metafield contains the customer's unique referral tracking code used for the referral program. This code can be shared with friends and family to track successful referrals and award referral bonuses. The code is automatically generated when a customer becomes eligible for the referral program.
Referral codes are unique, URL-safe strings that remain constant throughout the customer's lifetime unless manually reset.
Properties
Type: String
Namespace: lantern
Return Values
| Scenario | Value | Type |
|---|---|---|
| Customer has referral code | Code string (e.g., "JOHN123") | String |
| Customer eligible but no code generated | null | null |
| Not eligible for referrals | null | null |
| Logged out | null | null |
Examples
Basic Referral Code Display
{% assign referral_code = customer.metafields.lantern.referral_code %}
{% if referral_code %}
<div class="referral-code-display">
<h4>Your Referral Code</h4>
<div class="code-container">
<code class="referral-code">{{ referral_code }}</code>
<button class="copy-btn" data-copy="{{ referral_code }}">Copy</button>
</div>
<p>Share this code with friends to earn rewards!</p>
</div>
{% endif %}