Frontend API

Use settings to make storefront apps responsive to admin preferences such as store name, locale, currency, etc. In addition to store properties described below, app-specific settings are included in the result set.

Example settings
{
  "store": {
    "id": "example",
    "name": "Example Store",
    "url": "https://example.swell.store",
    "country": "US",
    "locale": "en-US",
    "support_email": "support@example.com",
    "support_phone": "(555) 555-5555",
    "currency": "USD",
    "public_key": "pk_cn6XsV3m28OjPuN68JdqYbbWJSUGbCqX",
    "currencies": [
      {
        "code": "USD",
        "rate": 1,
        "name": "US Dollar",
        "symbol": "$",
        "decimals": 2,
        "type": "base"
      },
      {
        "code": "EUR",
        "rate": 0.82542,
        "name": "Euro",
        "symbol": "€",
        "decimals": 3,
        "type": "display"
      }
    ],
    "analytics_scripts": "...",
    "facebook_pixel_id": "..."
  },

  // app-specific settings...
}

Methods to retrieve settings may return a promise if all settings haven't been loaded yet.

Returns the entire store settings object.

Get all settings
await swell.settings.get()

Returns a value from the store settings object using path notation, with an optional default if the value is undefined.

Get settings by path
await swell.settings.get('colors.primary.dark', '#000000')

Returns an object representing store settings, and saves it to an internal cache for accessing synchronously.

We recommend calling load() when initially loading a storefront so that all other calls to get() will be synchronous.

Load all settings
await swell.settings.load()

Returns an array containing store navigation menus, and saves it to an internal cache for accessing synchronously.

Retrieve all nav menus
await swell.settings.menus()

Returns a single navigation menu object.

Get nav menu by ID
await swell.settings.menus('header')

Returns an object representing payment settings and saves it to an internal cache for use with checkout methods.

Retrieve payment settings
await swell.settings.payments()