Loyalty & Rewards: Javascript API

  • Updated

Purpose: Verified, copy-paste-ready reference for the docs-review update of the Loyalty & Rewards: Javascript API article. This file is scoped to the JS API/methods for controlling the loyalty launcher (the sibling Events article covers events).


Overview

The Launcher JavaScript API exposes methods on the global StampedFn object. Use them to control the loyalty launcher programmatically. Each method is called on StampedFn; some take a view-key string or an options object, as shown below.


Launcher control

Open/close the launcher

StampedFn.toggleRewardsModal();

Opens the launcher if closed, closes it if open. (StampedFn.toggleLauncher() does the same thing.)


Loading launcher views

Use loadLauncherView(viewKey) to open a specific card view inside the launcher. viewKey is a string. All view keys below are confirmed valid.

Referrals view

StampedFn.loadLauncherView('view-referrals-email');

Loads the Referral section of the launcher.

Spendings view

StampedFn.loadLauncherView('view-spendings');

Loads the Redeem for Discounts (spendings) view.

Earnings view

StampedFn.loadLauncherView('view-earnings');

Loads the Ways to Earn Points (earnings) view.

Your Rewards view

StampedFn.loadLauncherView('view-your-rewards');

Loads the Your Rewards view.

View Key Card View
view-referrals-email Referral section
view-spendings Redeem for Discounts (spendings)
view-earnings Ways to Earn Points
view-your-rewards Your Rewards

Note: view-spendings and view-referrals-email do not appear as literal strings in the client bundle because loadLauncherView resolves views server-side by key. Both are valid and working — confirmed by the team.


Options

Copy the redeemed coupon code (instead of auto-applying)

StampedFn.setOptions({ is_rewards_code_copy: true });

By default, redeeming a reward auto-applies the discount at checkout. Setting is_rewards_code_copy: true makes the redeemed coupon copy to the clipboard instead, so the customer can paste it themselves. is_rewards_code_copy is a verified config flag (read in the coupon-apply logic).


Other verified launcher-control methods (optional additions)

These are not in the current article but are verified on StampedFn and may be useful to document:

Method What it does Example
StampedFn.toggleLauncher() Opens/closes the launcher (alias of toggleRewardsModal) StampedFn.toggleLauncher();
StampedFn.scrollLauncherView(selector) Scrolls the launcher to a specific element StampedFn.scrollLauncherView('.some-card');
StampedFn.getLoggedInCustomer() Returns the currently logged-in customer object const c = StampedFn.getLoggedInCustomer();
StampedFn.getDataRewards() Returns the loaded rewards data object const d = StampedFn.getDataRewards();
StampedFn.rewardsPointsRefresh() Refreshes the customer's points balance StampedFn.rewardsPointsRefresh();

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request