selectShippingAddress$(): Observable<Address | null>¶
The selectShippingAddress$
method allows to get a current shipping address in a basket.
Returned value¶
A returned value has a type of Observable<Address | null>
where Address represents an address object.
Example¶
In this example we make a basketAddressesApi
call to get a current shipping address in the basket.
useStorefront(async (storefront) => {
let basketAddressesApi = storefront.getApiSync('basketAddressesApi');
if (!basketAddressesApi) {
const featureSystemApi = this.getApiSync('FeatureSystemApi');
await featureSystemApi.registerDynamic('basket');
basketAddressesApi = storefront.getApiSync('basketAddressesApi');
}
const shippingAddress$ = basketAddressesApi.selectShippingAddress$();
shippingAddress$.subscribe((currentShippingAddress) => {
// do something with the address
})
});
Basket Address API methods reference¶
- getShippingAddress
- setShippingAddress
- getBillingAddress
- selectBillingAddress$
- setBillingAddress
- isBillingAddressEqualShippingAddress
- selectIsBillingAddressEqualShippingAddress$
- isDifferentShippingAddressRequired
- selectIsDifferentShippingAddressRequired$
- setBillingAddressAsShippingAddress
- getSectionValidation
- selectSectionValidation$