ChemPal Documentation - v1.12.0
    Preparing search index...

    Function shipsToCountry

    • Whether a supplier with the given shipping metadata ships to location. Prefers the explicit shipsTo allowlist when the supplier declares one; otherwise falls back to the coarse shipping scope — "worldwide"/"international" ship anywhere, while "domestic"/"local" ship only within the supplier's own country.

      Parameters

      • meta: ShippingMeta

        The supplier's shipping/country/shipsTo metadata.

      • location: valueof

        Destination country (ISO 3166-1 alpha-2).

      Returns boolean

      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;
      }
      }