Skip to content

selectLoyaltyPointsCost$(): Observable<LoyaltyPoints | null>

The selectLoyaltyPointsCost$ method allows to select the cost of exchanged items in points.

Returned value

A returned value has a type of Observable<LoyaltyPoints | null> where LoyaltyPoints represents a model of loyalty points.

Example

In this example we make a basketLoyaltyApi call to select the cost of exchanged items in points

useStorefront(async (storefront) => {
    let basketLoyaltyApi = storefront.getApiSync('basketLoyaltyApi');

    if (!basketLoyaltyApi) {
        const featureSystemApi = storefront.getApiSync('FeatureSystemApi');
        await featureSystemApi.registerDynamic('basket');

        basketLoyaltyApi = storefront.getApiSync('basketLoyaltyApi');
    }

    const loyaltyPointsCost$ = basketLoyaltyApi.selectLoyaltyPointsCost$();

    loyaltyPointsCost$.subscribe((loyaltyPointsCost) => {
        console.log('The cost of items exchanged in a loyalty program: ', loyaltyPointsCost);
    });
});

Basket Loyalty API methods reference

Models reference