Skip to content

selectActions$(): Observable<TBasketActions>

The selectActions$ method allows to select a key value object with various basket actions.

Returned value

A returned value has a type of Observable<TBasketActions> representing an object with basket actions inside.

Example

In this example we make a basketOverallApi call to select an action for changing a billing address in order to set its new value. We also use a getBillingAddress method from Basket Overall API API to get the action for setting the billing address with the retrieved action.

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

        let changeBillingAddressAction;

        basketOverallApi.selectActions$().subscribe((basketActions) => {
            changeBillingAddressAction = basketActions.changeBillingAddress;
        });

        await basketAddressesApi.setBillingAddress(changeBillingAddressAction, {
            isCompany: false,
            companyName: '',
            firstName: 'John',
            lastName: 'Snow',
            personalIdNumber: '',
            taxId: '',
            countryId: 'US',
            city: 'My City',
            postalCode: '12-345',
            street: 'example street 8',
            street2: '',
            phone: '123456789',
            state: '',
            useAsBillingAddress: false,
            createUserAccount: false
        });
    });
});

Basket Overall API methods reference

Objects reference