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 config
public method.
Snipcart.execute('config', '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.execute('config', 'credit_cards', [
{'type': 'visa', 'display': 'Visa'},
{'type': 'mastercard', '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.
Snipcart.execute('config', 'allowed_shipping_methods', [
'fedex-2-day',
'fedex-express-saver'
]);
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.execute('config', '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.execute('config', 'show_cart_automatically', true);
shipping_same_as_billing
By default, the checkbox Use this address for shipping on the billing address tab is selected. If you want to change this behavior, you can use the shipping_same_as_billing
configuration.
Use this setting if you want the checkbox to be selected by default:
Snipcart.execute('config', 'shipping_same_as_billing', true);
If you don't want the checkbox to be selected by default, use this one:
Snipcart.execute('config', 'shipping_same_as_billing', false);
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.execute('config', 'allowed_provinces', [
{ country: 'CA', provinces: ['QC', 'ON'] },
{ country: 'US', provinces: ['OH', 'CA'] },
]);
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.execute('config', 'show_continue_shopping', true);
show_place_order_on_top
Use this configuration setting if you want to show the Place order button in the header of the cart. This can be useful for merchants using PayPal Express Checkout, sometimes the place order button might be out of the browser viewport.
Snipcart.execute('config', 'show_place_order_on_top', true);