🚀 Simple Commerce v4.0 is out! Improvements to coupons & more!

Simple Commerce Logo

Customers

Tags

There's a {{ sc:customer }} tag which lets you loop through customers & loop through a specific customers' orders. You may review it's documentation seperatly.

Drivers

Simple Commerce supports three different customer drivers:

  • Entries: Customers will be stored as normal collection entries (Default)
  • Users: Customers will be stored as users - recommended if you want your customers to be able to login
  • Database: Used in combination with Database Orders

Entries Driver

By default, customers are stored as Statamic Entries, similar to orders, products and coupons.

They live in their own customers collection, which you can change if you need to in the simple-commerce.php config file.

1/*
2|--------------------------------------------------------------------------
3| Content Drivers
4|--------------------------------------------------------------------------
5|
6| Normally, all of your products, orders, coupons & customers are stored as flat
7| file entries. This works great for small stores where you want to keep everything
8| simple. However, for more complex stores, you may want store your data somewhere else
9| (like a database). Here's where you'd swap that out.
10|
11| https://simple-commerce.duncanmcclean.com/extending/content-drivers
12|
13*/
14 
15'content' => [
16 // All the other bits..
17 
18 'customers' => [
19 'repository' => \DoubleThreeDigital\SimpleCommerce\Customers\Customer::class,
20 'collection' => 'customers',
21 'collection' => 'members',
22 ],
23],

Users Driver

Storing your customers as users can often be handy if you're building some sort of membership site or if you want a way for your customers to log in, to view order history etc.

Hot Tip: You'll need to enable Statamic Pro if you want to store your customers as users.

To enable, change \DoubleThreeDigital\SimpleCommerce\Customers\EntryCustomerRepository::class to \DoubleThreeDigital\SimpleCommerce\Customers\UserCustomerRepository::class.

1/*
2|--------------------------------------------------------------------------
3| Content Drivers
4|--------------------------------------------------------------------------
5|
6| Normally, all of your products, orders, coupons & customers are stored as flat
7| file entries. This works great for small stores where you want to keep everything
8| simple. However, for more complex stores, you may want store your data somewhere else
9| (like a database). Here's where you'd swap that out.
10|
11| https://simple-commerce.duncanmcclean.com/extending/content-drivers
12|
13*/
14'content' => [
15 // All the other bits..
16 
17 'customers' => [
18 'repository' => \DoubleThreeDigital\SimpleCommerce\Customers\EntryCustomerRepository::class,
19 'repository' => \DoubleThreeDigital\SimpleCommerce\Customers\UserCustomerRepository::class,
20 ],
21],

You'll then want to change the fieldtype of the 'Customer' field on the Orders blueprint to a Users field. You will need to delete & create a new field to do this. You may need to also change any references to old customer entries in your Order entries to point to the correct user IDs.

Database Driver

There's separate documentation on Database Orders (& Customers).