Retrieve all active earning rules configured for the shop. Use this to display how customers can earn points.
Usage
MageSDK.getEarningRules().then(function(resp) {
if (resp.success) {
resp.data.earningRules.forEach(function(rule) {
console.log(rule.name, rule.pointsToGive);
});
}
});
Response
Whether the request was successful.
List of active earning rules.Show Earning rule properties
Internal name of the rule.
Description of how points are earned.
The trigger action (e.g. "place_order", "create_account", "birthday").
Rule category (e.g. "purchase", "social", "engagement").
Whether the rule is currently active.
Number of points awarded.
Label to display to customers.
URL for the call-to-action button, or null if not set.
The customer’s specific earning record for this rule, or null if the customer hasn’t triggered it.
Sample response
{
"success": true,
"data": {
"earningRules": [
{
"id": "rule_abc",
"name": "Points for purchase",
"description": "Earn 10 points per \u00a31 spent",
"action": "place_order",
"category": "purchase",
"isActive": true,
"pointsToGive": 10,
"customerFacingLabel": "Earn 10 points per \u00a31 spent",
"callToActionUrl": null,
"customerEarningRule": null
}
]
}
}