selectLoyalty$(): Observable<UserLoyalty | null>¶
The selectLoyalty$
method allows you to get the observable with the object of properties regarding the loyalty program for a currently authenticated user.
Returned value¶
A returned value has a type of Observable<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 select a loyalty for a current user.
useStorefront(async (storefront) => {
const userApi = await storefront.getApi('UserApi');
const loyalty$ = userApi.selectLoyalty$();
loyalty$.subscribe((currentLoyalty) => {
console.log('current amount of loyalty points:', loyalty.points);
console.log('current user discount:', loyalty.currentDiscount);
})
});
User API methods reference¶
- getUser
- selectUser$
- getOrders
- selectOrders$
- getAddresses
- selectAddresses$
- isProductNotificationPossible
- selectIsProductNotificationPossible$
- getLoyalty
- getLoyaltyPoints
- selectLoyaltyPoints$