🎉 Simple Commerce v3.0 is out! Includes new features & some big quality of life improvements.

Simple Commerce Logo

Multi-site

Simple Commerce has first-party support for being used with Statamic's multi-site functionality.

In fact it's the way we'd recommend implementing multi-currency or multi-country sites. Each currency/country should be it's own Statamic site.

Each Statamic site you have setup in your config/statamic/sites.php config should also be setup in the Simple Commerce config (located at config/simple-commerce.php)

1/*
2 |--------------------------------------------------------------------------
3 | Sites
4 |--------------------------------------------------------------------------
5 |
6 | For each of your Statamic sites, you can setup a new store which allows you
7 | to use different currencies, tax rates and shipping methods.
8 |
9 */
10 
11'sites' => [
12 'default' => [
13 'currency' => 'GBP',
14 
15 'tax' => [
16 'rate' => 20,
17 'included_in_prices' => false,
18 ],
19 
20 'shipping' => [
21 'methods' => [
22 \DoubleThreeDigital\SimpleCommerce\Shipping\StandardPost::class,
23 ],
24 ],
25 ],
26],

When you create an additional Statamic site, just add a new key to the sites array, like so:

1'sites' => [
2 'default' => [...],
3 'french' => [...],
4],

Remember that the site key will need to be the same one as used in your sites.php configuration file.

🔥 Hot Tip: Also remember that if you're wanting to use multiple sites, you'll need to purchase & enable Statamic Pro.

With each site you can configure the currency being used and the tax rate applied to products in the customers' cart.

Carts

By default, Simple Commerce will give each site it's own cart. Meaning if you add a product to your cart on one site, it won't also be added to the cart of the user on another site.

If you're using subdirectories for your multi-sites, it's recommended you provide a different URL for each site's cart/checkout pages. So instead of all sites using /checkout/information, they would use /gb/checkout/information or /de/checkout/information.

It's pretty simple to do - loop through your sites & provide a route prefix.

1// routes/web.php
2
3foreach (Site::all() as $site) {
4 Route::prefix($site->url())->group(function () use ($site) {
5 Route::statamic('/cart', 'cart', ['title' => 'Your Cart']);
6
7 Route::statamic('/checkout/information', 'checkout.information');
8 Route::statamic('/checkout/shipping', 'checkout.shipping');
9 Route::statamic('/checkout/payment', 'checkout.payment');
10 Route::statamic('/checkout/complete', 'checkout.complete');
11 });
12}

Using the same cart between sites

If, for whatever reason you find yourself needing to use the same cart between all of your sites. Add a cart.single_cart option to your config file.

1// config/simple-commerce.php
2 
3/*
4|--------------------------------------------------------------------------
5| Cart
6|--------------------------------------------------------------------------
7|
8| Configure the Cart Driver in use on your site. It's what stores/gets the
9| Cart ID from the user's browser on every request.
10|
11*/
12 
13'cart' => [
14 'repository' => \DoubleThreeDigital\SimpleCommerce\Orders\Cart\Drivers\CookieDriver::class,
15 'key' => 'simple-commerce-cart',
16 'single_cart' => false,
17],

Code highlighting provided by Torchlight.

Edit this page