Simple Commerce Logo

Upgrade Guide

When upgrading from v2.2 to v2.3, please read through this guide in case there's anything you need to change. Most of the updates around the configuration file and blueprint changes have been automated to help speed up the process.

You may also review the changes manually if you wish.

In your composer.json file, change the doublethreedigital/simple-commerce version constraint:

1"doublethreedigital/simple-commerce": "2.3.*"

Then run:

1composer update doublethreedigital/simple-commerce --with-dependencies

High: Gateways

Built-in gateway namespace changes

The namespace of all built-in gateways (Dummy, Stripe & Mollie) have been updated from Gateways\GatewayName to Gateways\Builtin\GatewayName.

If you're using one of these gateways, you must update the namespace in your simple-commerce.php config file.

Note: this is one of the upgrade steps that's automated for you.

1/*
2|--------------------------------------------------------------------------
3| Gateways
4|--------------------------------------------------------------------------
5|
6| You can setup multiple payment gateways for your store with Simple Commerce.
7| Here's where you can configure the gateways in use.
8|
9| https://simple-commerce.duncanmcclean.com/gateways
10|
11*/
12 
13'gateways' => [
14 \DoubleThreeDigital\SimpleCommerce\Gateways\Builtin\DummyGateway::class => [
15 'display' => 'Card',
16 ],
17],

Custom gateway namespace changes

If you're using a custom gateway, please update the namespaces of the Data Transfer Objects (DTOs) provided by SC.

1// Before
2use DoubleThreeDigital\SimpleCommerce\Data\Gateways\BaseGateway;
3use DoubleThreeDigital\SimpleCommerce\Data\Gateways\GatewayPrep;
4use DoubleThreeDigital\SimpleCommerce\Data\Gateways\GatewayPurchase;
5use DoubleThreeDigital\SimpleCommerce\Data\Gateways\GatewayResponse;
6
7// Now
8use DoubleThreeDigital\SimpleCommerce\Gateways\BaseGateway;
9use DoubleThreeDigital\SimpleCommerce\Gateways\Prepare;
10use DoubleThreeDigital\SimpleCommerce\Gateways\Purchase;
11use DoubleThreeDigital\SimpleCommerce\Gateways\Response;

High: Email notifications

Previously, Mailables were used to send email notifications to customers and store owners.

However, in order to easily support more notification types in the future, I've changed the way email notifications work. They now use Laravel's Notifications feature.

Updated configuration

You may now specifiy multiple notifications for an 'event'. You can also specify who you'd like each of the notifications to be sent to. You can choose from

1/*
2|--------------------------------------------------------------------------
3| Notifications
4|--------------------------------------------------------------------------
5|
6| Simple Commerce can automatically send notifications after events occur in your store.
7| eg. a cart being completed.
8|
9| Here's where you can toggle if certain notifications are enabled/disabled.
10|
11| https://simple-commerce.duncanmcclean.com/email
12|
13*/
14
15'notifications' => [
16 'order_paid' => [
17 \DoubleThreeDigital\SimpleCommerce\Notifications\CustomerOrderPaid::class => ['to' => 'customer'],
18 \DoubleThreeDigital\SimpleCommerce\Notifications\BackOfficeOrderPaid::class => ['to' => 'duncan@example.com'],
19 ],
20],

Note: this is one of the upgrade steps that's automated for you.

Medium: Events

I've updated the names of events, the parameters available in events and there's a few events which have also been removed. A full list of changes is available below:

CartUpdated

This event has been removed.

CouponRedeemed

Previously the $coupon was an Entry instance, this has been changed to a Coupon instance.

1public function handle(CouponRedeemed $event)
2{
3 $event->coupon; // is now a Coupon
4}

CustomerAddedToCart

This event has been removed. In place, I'd recommend listening for order entries being updated and checking if the customer field has been changed.

CartCompleted -> OrderPaid

This event has been renamed OrderPaid. Additionally, the $cart parameter has been removed, $order should now be used (all of the same methods are available).

1public function handle(OrderPaid $event)
2{
3 $event->order; // will return an Order, should be used in place of $cart
4}

CartSaved -> OrderSaved

This event has been renamed OrderSaved. Additionally, the $cart parameter has been removed and a $order parameter has been added.

The $order parameter will return an Order instance.

1public function handle(OrderSaved $event)
2{
3 $event->order; // will return an Order, should be used in place of $cart
4}

PostCheckout

Previously, only an order's data array was passed into this event. However, now the full $order is available.

1public function handle(PostCheckout $event)
2{
3 $event->order; // will return an Order
4}

PreCheckout

Previously, only an order's data array was passed into this event. However, now the full $order is available.

1public function handle(PreCheckout $event)
2{
3 $event->order; // will return an Order
4}

Medium: Translations

I've simplified the translations into a single file, messages.php. If you were previously using your own translations, please review the updated file.

Medium: Custom Data Classes

To help with future features I've got planned (👀), I've updated a few things around custom data classes.

Note: You'll now find me referring to these as 'content drivers'.

Updates to binding your custom data class

Instead of directly binding to the service container in your AppServiceProvider.php file, please bind your data class from inside the simple-commerce.php config file.

1/*
2|--------------------------------------------------------------------------
3| Content Drivers
4|--------------------------------------------------------------------------
5|
6| Simple Commerce stores all products, orders, coupons etc as flat-file entries.
7| This works great for store stores where you want to keep everything simple. But
8| sometimes, for more complex stores, you may want use a database instead. To do so,
9| just swap out the 'content driver' in place below.
10|
11*/
12 
13'content' => [
14 'orders' => [
15 'driver' => \DoubleThreeDigital\SimpleCommerce\Orders\Order::class,
16 'collection' => 'orders',
17 ],
18 
19 'products' => [
20 'driver' => \DoubleThreeDigital\SimpleCommerce\Products\Product::class,
21 'collection' => 'products',
22 ],
23 
24 'coupons' => [
25 'driver' => \DoubleThreeDigital\SimpleCommerce\Coupons\Coupon::class,
26 'collection' => 'coupons',
27 ],
28 
29 'customers' => [
30 'driver' => \DoubleThreeDigital\SimpleCommerce\Customers\Customer::class,
31 'collection' => 'customers',
32 ],
33],

When updating, we will automate the change of configuration format. However, it will not automatically switch it to your custom driver/data class.

Contract changes

I've also made various changes to the contracts implemented by custom drivers/data classes. You may review the changes on GitHub.

Low: Cart facade

Like mentioned in the v2.2 upgrade guide, the Cart facade has now been completley removed.

You should now use the Order facade which provides all of the same methods.

1// Before
2Cart::find('abc-123');
3 
4// After
5Order::find('abc-123');

Please feel free to reach out if you've got any questions about upgrading! I'm always happy to help.

Need some help?

There's plenty of ways of getting help: either via opening a GitHub Issue, starting a conversation on the Statamic Discord or directly emailing me.