selectSelectedShippingCountry$(): Observable<ShippingCountry | undefined>¶
The selectSelectedShippingCountry$
method allows you to observe the currently selected shipping country.
Returned value¶
A returned value has a type of Observable<ShippingCountry | undefined>
where ShippingCountry
represents the ShippingCountry model.
Example¶
In this example, we make a basketShippingsApi
call to observe the currently selected shipping country.
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 selectedShippingCountry$ = basketShippingsApi.selectSelectedShippingCountry$();
selectedShippingCountry$.subscribe((shippingCountry) => {
if (shippingCountry) {
console.log('Currently selected shipping country:', shippingCountry.name);
} else {
console.log('No shipping country is currently selected.');
}
});
});
Basket Address API methods reference¶
- get
- select
- setShipping
- setPickupPoint
- getSelectedShipping
- selectSelectedShipping
- getAvailableShippingCountries
- selectAvailableShippingCountries
- getSelectedShippingCountry
- setCountry
- getPaymentCostForActiveShippingByPaymentId
- selectPaymentCostForActiveShippingByPaymentId
- isEveryAvailablePaymentFree
- selectIsEveryAvailablePaymentFree
- getSectionValidation
- selectSectionValidation
- addMap
- showPickupPointMap
- shouldDisplayRemainingBasketValueForFreeShippingMessage
- addShippingInfo
- getShippingInfo