Skip to content

shouldDisplayRemainingBasketValueForFreeShippingMessage(shipping: BasketShipping): boolean

The shouldDisplayRemainingBasketValueForFreeShippingMessage method allows to determine if the message about the free shipping for the remaining basket should display based on the shipping option.

Input parameters

shipping

shipping is a mandatory parameter of the BasketShipping type that represents the shipping we want to check.

Returned value

A returned value has a type of boolean. If the message should be displayed it returns true, otherwise it returns false.

Example

In this example we make a basketShippingsApi call to determine if the message about the free shipping for the remaining basket should display for a currently selected shipping option.

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

    if (!basketShippingsApi) {
        const featureSystemApi = this.getApiSync(FEATURE_SYSTEM_API_NAME);
        await featureSystemApi.registerDynamic('basket');

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

    const selectedShipping$ = basketShippingsApi.selectSelectedShipping$();

    selectedShipping$.subscribe((shippingOption) => {
        if (!shippingOption) {
            console.log('No shipping option is currently selected.');
            return;
        }

        const shouldDisplayMessage = basketShippingsApi.shouldDisplayRemainingBasketValueForFreeShippingMessage(shippingOption);

        if (shouldDisplayMessage) {
            console.log('Message should be displayed!');
            // and some additional logic displaying a message
        }
    });
});

Basket Address API methods reference

Models reference