The supplier's shipping/country/shipsTo metadata.
Destination country (ISO 3166-1 alpha-2).
True when the supplier ships to location.
shipsToCountry({ shipping: 'domestic', country: 'US' }, 'DE'); // => false
shipsToCountry({ shipping: 'domestic', country: 'US', shipsTo: ['US', 'CA'] }, 'CA'); // => true
export function shipsToCountry(meta: ShippingMeta, location: CountryCode): boolean {
if (meta.shipsTo) {
return meta.shipsTo.includes(location);
}
switch (meta.shipping) {
case 'worldwide':
case 'international':
return true;
case 'domestic':
case 'local':
return meta.country === location;
default:
return true;
}
}
Whether a supplier with the given shipping metadata ships to
location. Prefers the explicitshipsToallowlist when the supplier declares one; otherwise falls back to the coarseshippingscope —"worldwide"/"international"ship anywhere, while"domestic"/"local"ship only within the supplier's owncountry.