swellAPI.getCustomerDetails()
This method returns an object containing all the program details about the logged-in customer. You can use this to create custom interfaces that display items like their current point balance, referral link, and earning/redemption history.
$(document).on("swell:setup", function(){
var customerDetails = swellAPI.getCustomerDetails();
$("#custom-point-balance-ui").html(customerDetails.pointsBalance);
$("#custom-referral-link-ui").html(customerDetails.referralLink);
customerDetails.actionHistoryItems.forEach(function(item) {
$("#custom-history-container").append(
"<li>" +
item.date + " -- " +
item.action + " -- " +
item.points +
"</li>");
});
})
vipTier:
description: "Earn VIP status after spending $200 in a calendar year"
id: 113
name: "VIP"
pointsMultiplier: "1.4"
vipTierSubscriptionDate: "2019-06-16T11:03:03.000Z"
vipTierExpirationDate: "2020-06-16T11:03:03.000Z"
Details Object
Attribute | Type | Description |
---|---|---|
| datetime | The timestamp this customer entered our database |
| array | The customer’s earning and redemption history |
| string | The customer’s email address |
| array | An array containing the customer’s point redemption history |
| int | The customer’s current point balance |
| int | The total number of points ever earned for this customer |
| array | An array containing the customer’s purchase history |
| string | The customer’s referral code (eg. abcd123) |
| string | The customer’s unique referral link |
| string | The customer’s unique referral discount code |
| int | An internal id for this customer’s referral discount code |
| int | The number of orders made with this customer’s referral discount code |
| array | An array containing the customer’s referral history |
| obj | An object with details about the customer’s current tier level |
| obj | An object with details about the customer’s current progress toward vip tiers |
| string | The customer’s paypal email used for receiving cash payouts |
| string | Total amount earned as part of the affiliate program |
| string | The customer’s payout percentage for the affiliate program |
| bool | Flag for whether or not this customer is an affiliate |
| array | An array containing the customer’s cash payouts history |
| array | An array containing all the products this customer has sold as an affiliate |
| boolean | Whether the customer is part of the loyalty program. |
| DateTime - ISO8601 | The date and time when the customer joined the loyalty program |
Action History Item Object
Attribute | Type | Description |
---|---|---|
| string | A short description of either the action/campaign completed or the redemption option earned/redeemed |
| datetime | A timestamp when this item was created |
| datetime | A timestamp when the customer completed the action |
| date | The date (without time) when this item was created |
| int | The number of points that were either earned or redeemed |
| string | If using a variable redemption option, the amount of credit earned or used |
| string | For campaigns this can either be |
Point Redemption Object
Attribute | Type | Description |
---|---|---|
| int | if |
| boolean | A flag for whether or not this redemption deducted the points from the customer’s balance before or after making a purchase. If |
| date | The timestamp of when this redemption was made |
| string | The currency of the store |
| int | The internal id of the customer who made the redemption |
| string | If the redemption is fulfilled externally and requires a link for the customer to claim then this can be used to store that URL. |
| int | The internal id for this redemption |
| boolean | A flag for whether or not this redemption happened on a Point of Sale system |
| int | If this redemption happened as part of completing a campaign this will hold the id of the perk responsible for rewarding the customer for completing that campaign. |
| object | The redemption option that was redeemed by the customer. |
| string | The coupon code or other text presented to the customer for making the redemption. |
| boolean | Whether or not this should show up in the customer’s history. |
Redemption Option Object
Attribute | Type | Description |
---|---|---|
| int | How many points this redemption option costs to redeem |
| string | The type of discount this redemption option represents. Can be things like |
| string | The name given in the Swell admin for this redemption option (e.g. “$5 Off”) |
Referral Object
Atribute | Type | Description |
---|---|---|
| datetime | When the referred customer made a purchase |
| int | The internal customer id for the referral |
| string | The email address of the referred customer |
| int | An internal id for this referral object |
| datetime | When the referred customer created an account |
| string | Where the referred customer came from |
| string | The hostname the referred customer came from |
VIP Tier Object
Attribute | Type | Description |
---|---|---|
| int | An internal id for this tier |
| string | The name of the tier |
| string | A short description of the tier requirements |
| decimal | The points multiplier for the current tier |
| datetime | The date and time the customer subscribed to the VIP tier |
| datetime | The date/time at which the VIP tier will expire for the customer |
VIP Tier Stats Object
Attribute | Type | Description |
---|---|---|
| int | How many points the customer has earned within the tier window |
| int | How many cents the customer has spent within the tier window |
| int | How many purchases the customer has made within the tier window |
| int | How many referrals the customer has made within the tier window |
VIP Tier Status Object
Attribute | Type | Description |
---|---|---|
| int | Object conveying the required thresholds for the customer to maintain their current tier |
| int | Object conveying the required thresholds for the customer to obtain the next tier |
Cash Payout Object
Attribute | Type | Description |
---|---|---|
| int | An internal id for this tier |
| int | The internal customer id for the referral |
| datetime | The timestamp when the payout is scheduled to happen |
| float | The amount the customer earned for this cash payout |
| string | The currency code for the cash payout (e.g “USD”) |
| string | The status of this cash payout |
| string | The paypal email this cash payout was or will be sent to |
| string | The amount of the purchase made that triggered this cash payout |
| datetime | The timestamp of when this cash payout was created |
Affiliate Product Sold Object
Attribute | Type | Description |
---|---|---|
| string | The title of the product sold by an affiliate |
| int | The amount of revenue generated in cents by the total sales of this product by this affiliate |
| int | How many of this product has been sold by this affiliate |