Skip to content

addMap(shipping: BasketShipping, mapStrategy: PickupPointMapStrategy): void

The addMap method allows to add a map for the shipping option using a specified map strategy.

Input parameters

shipping

shipping is a mandatory parameter of the BasketShipping type that represents the shipping we want to add a map for.

mapStrategy

mapStrategy is a mandatory parameter of the PickupPointMapStrategy type which represents a strategy of showing a map.

Returned value

A returned value has a type of void as this method returns nothing.

Example

In this example we make a basketShippingsApi call to add a map for the selected shipping option.

useStorefront(async ({ eventBus, getApi }) => {
    eventBus.on('basket.initialized', async () => {
        const basketShippingsApi = await getApi('basketShippingsApi');

        class ExampleDeliveryPointMap {
            public async showMap(choosePickupPointCallback) {
                choosePickupPointCallback();
                // here goes code for map handling
            }
        }

        class ExamplePickupPointMapStrategy {
            public execute() {
                return ExampleDeliveryPointMap;
            }
        }

        const selectedShipping = basketShippingsApi.getSelectedShipping()

        const basketShippingOptions = basketShippingsApi.addMap(selectedShipping, ExamplePickupPointMapStrategy);
    });
});

Basket Address API methods reference

Models reference