Configuration

Through the configuration API, you will be able to set some Snipcart settings such as allowed credit cards.

Basics

To set a configuration value, you will need to use our configure public API method.

Snipcart.api.configure('key', 'value');

You can chain multiple calls to the configure.

Snipcart.api
  .configure('key', 'value')
  .configure('key', 'value');

credit_cards

Use it to specify which credit cards you want available during checkout. The default cards are visa, mastercard and amex

Snipcart.api.configure('credit_cards', [
  {'type': 'visa', 'display': 'Visa'},
  {'type': 'matercard', 'display': 'Mastercard'}
]);

Supported card types are:

  • visa
  • mastercard
  • maestro
  • amex
  • dinersclub
  • discover
  • jcb
  • cardbleue
  • dankort
  • cartasi
  • postepay

Please let us know at geeks@snipcart.com if we missed any credit card type!

allowed_shipping_methods

When using an integrated shipping provider like USPS, you may need to hide shipping methods that you don't want to support. Each shipping rate is identified by a slug, I suggest you to inspect the shipping methods screen and look at the css classes that are added to the shipping rate DOM element. The slug is the css class name, without the snipcart- prefix. If this setting is not specified, all the shipping methods will be displayed to your customer.

Shipping method slug

Snipcart.api.configure('allowed_shipping_methods', [
    'fedex-2-day',
    'fedex-express-saver'
]);

excluded_shipping_methods

Use this configuration to exclude a shipping rate that can be returned by a carrier. Please note that USPS Media Mail is excluded by default, if you need this option you'll need to remove it using this option.

The following example removes all excluded shipping methods, can be useful if you want to enable USPS Media Mail.

Snipcart.api.configure('excluded_shipping_methods', ['']);

The other example shows how to exclude any shipping rate that can be returned by a carrier:

Snipcart.api.configure('excluded_shipping_methods', ['fedex-express']);

show_cart_automatically

If you want to prevent the cart from showing up everytime a product is added, you can use the show_cart_automatically configuration to disable it.

This setting will prevent the cart from always popping up when a customer adds a product to it:

Snipcart.api.configure('show_cart_automatically', false);

On the opposite, this following setting will force the cart to always pop up when a customer adds a product:

Snipcart.api.configure('show_cart_automatically', true);

shipping_same_as_billing

By default, the checkbox Use this address for shipping on the billing address tab is not selected. If you prefer to make it selected by default you can use the shipping_same_as_billing configuration.

Use this setting if you want the checkbox to be selected by default:

Snipcart.api.configure('shipping_same_as_billing', true);

If you don't want the checkbox to be selected by default, use this one:

Snipcart.api.configure('shipping_same_as_billing', false);

allowed_countries

Use this configuration setting if you want to filter countries that will be displayed in the cart. In the billing and shipping information tabs, a customer will only be showed the countries that are allowed.

Snipcart.api.configure('allowed_countries', ['CA']);

allowed_provinces

Use this configuration setting if you want to filter the provinces/states that will be displayed in the cart. In the billing and shipping information tabs, when a customer selects a country, we show them a list of available provinces. If you only ship to specific provinces, you can filter them.

Snipcart.api.configure('allowed_provinces', [
  { country: 'CA', provinces: ['QC', 'ON'] },
  { country: 'US', provinces: ['OH', 'CA'] },
]);

provinces_for_country

Use this configuration settings if you want to add provinces to a country with none by default. For example, by default Australia does not have any provinces in the cart, the province field will be a simple textbox. The example below will add two provinces to Australia.

Snipcart.api.configure('provinces_for_country', [{
    country: 'AU',
    provinces: [
      { code: 'TAS', name: 'Tasmania' },
      { code: 'VIC', name: 'Victoria' },
    ]
}]);

show_continue_shopping

Use this configuration setting if you want to show the Continue shopping button. This button will appear just beside the close cart button.

Snipcart.api.configure('show_continue_shopping', true);

split_firstname_and_lastname

Use this configuration setting to split the First name and Last name in the billing address and shipping address forms.

Snipcart.api.configure('split_firstname_and_lastname', true);