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

Simple Commerce Logo

Control Panel

Once installed, Simple Commerce will create a 'Simple Commerce' section in the Control Panel Nav for your users to access Orders, Products, etc without needing to go via the Collections menu.

Simple Commerce will also give you an 'Overview' page which lets you get a top-level picture of your e-commerce store, there's more documentation on that below:

'Overview' Page

Overview Screenshot

The 'Overview' page gives you and your users a quick overview of your e-commerce store.

By default, all 'widgets' will be visible to you. If you wish you hide a certain widget, you may do so with the 'Configure' button at the top right of the page. Your preferences will be saved for future.

Automatically redirecting users to the 'Overview' after logging in

Statamic lets you automatically redirect users to a specific URL after logging them in. By default, it'll redirect them the Dashboard page. However, if you wish, you may redirect them to Simple Commerce's Overview page.

Simply update the start_page value in your config/statamic/cp.php config file:

1/*
2|--------------------------------------------------------------------------
3| Start Page
4|--------------------------------------------------------------------------
5|
6| When a user logs into the Control Panel, they will be taken here.
7| For example: "dashboard", "collections/pages", etc.
8|
9*/
10 
11'start_page' => 'simple-commerce/overview',

Registering a custom 'overview widget'

You may build your own Overview Widgets. There's two parts of a widget: backend & frontend.

Back-end

To register an overview widget, simply add something like this to your AppServiceProvider (or similar):

1static::registerWidget(
2 'orders-chart',
3 [
4 'name' => 'Orders Chart',
5 'component' => 'overview-orders-chart',
6 ],
7 function (Request $request) {
8 return [];
9 }
10);

The first parameter should be the 'handle' of the widget, the second parameter should be an array which contains both a name and a component. Finally, the last parameter should be a 'callback' which will be used to gather 'data' for your widget.

Front-end

After you've got your back-end sorted for your widget, you'll need to get the front-end sorted. The front-end requires you to setup a Vue component which is loaded in the Control Panel (you may read about how to do this over on the Statamic docs).

A blank widget component may look something like this:

1<template>
2 <div class="flex-1 card p-0 overflow-hidden h-full">
3 <div class="flex justify-between items-center p-2 pb-1">
4 <h2>
5 <span>Basic Widget</span>
6 </h2>
7 </div>
8 
9 <p>Hello world!</p>
10 </div>
11</template>
12 
13<script>
14export default {
15 props: {
16 data: Array,
17 },
18};
19</script>

The data prop will be what's returned from your PHP callback.