Installation
Follow the instructions below to setup Snipcart for Statamic.

Install Addon

Option 1: Install the addon with Composer.
1
composer require aerni/snipcart
Copied!
Option 2: Install the addon through the Addons section in the Statamic Control Panel.

Perform Basic Configuration

The installation process will automatically publish the addon's config to config/snipcart.php. Open the config and perform the following configuration:
    1.
    Sites: Add the desired currency, length, and weight units for each of your sites
    2.
    Collections & Taxonomies: Define the handles for your products collection and categories taxonomy

Run Setup Command

After configuring your Sites and Collection & Taxonomies you need to run the setup command. This command will create all the necessary collections, taxonomies, and blueprints to get you started.
1
php please snipcart:setup
Copied!

Add Snipcart API Keys

Add your Snipcart API keys to your .env file. You can find them in your Snipcart dashboard.
1
SNIPCART_LIVE_KEY=************************
2
SNIPCART_LIVE_SECRET=************************
3
4
SNIPCART_TEST_KEY=************************
5
SNIPCART_TEST_SECRET=************************
Copied!

Add Webhook URL

Add the absolute URL of your Snipcart Webhook to your Snipcart Dashboard, eg. https://my-shop.com/webhooks/snipcart
You can customize the webhook route in the config. The default route is webhooks/snipcart.

Setup Views

Head Tag

Add this tag to the <head> in your view to render Snipcart's preconnect hints and stylesheet.
1
{{ snipcart:head }}
Copied!
If you want more control, you may add the preconnect hints and stylesheet separately instead.
1
{{ snipcart:preconnect }}
2
{{ snipcart:stylesheet }}
Copied!

Body Tag

Add this tag before the closing </body> in your view to render Snipcart's container and script.
1
{{ snipcart:body }}
Copied!
If you want more control, you may add the container and script separately instead. Just make sure to include the script after the container.
1
{{ snipcart:container }}
2
{{ snipcart:script }}
Copied!
Last modified 7mo ago