getLoyalty(): UserLoyalty | null¶
The getLoyalty
method allows you to get the object of properties regarding the loyalty program for a currently authenticated user.
Returned value¶
A returned value has a type of UserLoyalty | null
where UserLoyalty is an object of properties regarding the loyalty program. null
will be returned if the loyalty program is not active.
Example¶
In this example we make a UserApi
call to get a loyalty for a current user.
useStorefront(async (storefront) => {
const userApi = await storefront.getApi('UserApi');
const loyalty = userApi.getLoyalty();
console.log('amount of loyalty points:', loyalty.points);
console.log('user discount:', loyalty.currentDiscount);
});
User API methods reference¶
- getUser
- selectUser$
- getOrders
- selectOrders$
- getAddresses
- selectAddresses$
- isProductNotificationPossible
- selectIsProductNotificationPossible$
- selectLoyalty$
- getLoyaltyPoints
- selectLoyaltyPoints$