> ## Documentation Index
> Fetch the complete documentation index at: https://strapi-suite.littlebox.pt/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Turn on the e-commerce module, set its environment variables and give your team the right permissions.

The e-commerce module turns Strapi into the back office of an online store. You manage the catalog, the customers,
the orders, the payments, the shipments, the invoices and the promotions in one place, and your storefront talks to
the module through a private API.

The module runs a single store. It is off by default, so nothing changes in Strapi until you turn it on.

## Requirements

Before you start, check that you have:

* the Littlebox Strapi Suite plugin installed in your Strapi project;
* access to the server environment, so you can set the environment variables listed below and restart Strapi;
* a storefront (your public website) that calls the storefront API. You can build it however you like. See the
  [frontend guide](https://strapi-suite.littlebox.pt/frontend/guides/ecommerce/overview.md).

The integrations are optional, and you turn on only the ones you need:

* **Stripe** to take card, MB WAY and other online payments;
* **Moloni** to issue certified invoices and credit notes;
* **DPD Portugal** and **CTT Expresso Portugal** to create shipments with a carrier;
* **Resend** to send e-mails to your customers.

## Turn the module on

**Step 1**: Access the Strapi admin panel.\
**Step 2**: Go to the *Littlebox Strapi Suite* and select "E-commerce". You can also click the
"Littlebox Strapi Ecommerce" shortcut in the main menu of Strapi.\
**Step 3**: The screen shows "The E-commerce module is disabled". Click "Enable E-commerce".

The module opens on the product list. Its side menu has these entries:

* **Products**: the catalog, with variants, prices, stock and images.
* **Categories**: the tree that organizes the products.
* **Collections**: groups of products, chosen by hand or by conditions.
* **Tags**: free labels for the products.
* **Orders**: every order, from the storefront or created by you.
* **Customers**: the people who bought or registered.
* **Promotions**: discounts, codes and gifts. It only shows when you can read promotions.
* **Settings**: the store, the API, the integrations, the e-mails and the scheduled jobs.

### Turn the module off

**Step 1**: Go to "Settings" and open the "General" tab.\
**Step 2**: In the "E-commerce module" card, click "Disable".\
**Step 3**: Confirm.

While the module is off, the store is closed:

* every e-commerce endpoint, in the admin and in the storefront API, answers `404 Not Found`, so the site cannot show products or take orders;
* Stripe payment notifications also get `404`, and Stripe retries them for up to 3 days;
* the module only shows the screen to turn it back on.

No data is deleted. Products, orders, customers and settings stay as they are.

## Environment variables

The module keeps secrets (integration passwords, API keys, customer passwords) safe with two kinds of server keys.
You set them in the environment of the Strapi server, for example in the `.env` file, and then you restart Strapi.

| Variable | What it does | Required |
| - | - | - |
| `LTB_ECOMMERCE_ENCRYPTION_KEY` | Encrypts the integration credentials, protects the customer e-mail addresses and signs the customer sessions. | Yes, to save any integration and to use customer accounts |
| `LTB_ECOMMERCE_PASSWORD_PEPPER_V1` | A secret mixed into every customer password before it is stored. `V1` is the version number. | Only for customer accounts (modes other than guest only) |

Generate each value with this command. It prints at least 32 random bytes in base64, which is the minimum for a pepper:

```bash theme={null}
openssl rand -base64 48
```

```bash .env theme={null}
LTB_ECOMMERCE_ENCRYPTION_KEY=paste-the-first-generated-value-here
LTB_ECOMMERCE_PASSWORD_PEPPER_V1=paste-the-second-generated-value-here
```

> [!NOTE]
>
> You can also set the encryption key in the plugin configuration as `ecommerce.encryptionKey`. When both exist, the
> plugin configuration wins.

**Without the encryption key**\
The General tab shows "The encryption key is not configured". Everything else keeps working, but you cannot save
integration credentials, and customer accounts are not available.

**Without a pepper**\
The module still starts. If you choose a customer accounts mode other than guest only, the General tab shows
"Customer accounts are not ready yet", and customers cannot sign in.

**Rotate the pepper**\
To change the pepper, add a new version, for example `LTB_ECOMMERCE_PASSWORD_PEPPER_V2`, and keep `V1` as it is. The
highest number is the current version. Each customer password moves to the new version the next time that customer
signs in. Keep the old versions set until no password uses them.

> [!WARNING]
>
> Never change the value of a pepper version that is already in use. Every password stored with it stops working. Also
> keep the encryption key stable: when it changes, the saved credentials can no longer be read (you must type them
> again) and every customer is signed out.

## Permissions

The module adds its own actions to Strapi roles. Go to **Settings → Administration Panel → Roles**, open a role, and
find them under **Plugins → Littlebox Strapi Suite → ecommerce**.

| Action | What it allows |
| - | - |
| Read products | See the products, categories, collections and tags. |
| Manage products | Create, edit, enable, disable and delete products, variants, images, categories, collections and tags. |
| Read settings | See every Settings tab, in read only mode. |
| Manage settings | Change the settings, turn the module off, configure integrations, generate the API token and edit e-mail templates. |
| Read orders | See the order list and the order details. |
| Manage orders | Create, duplicate and edit orders, add manual payments, ship, register returns, archive and cancel, and resend e-mails. |
| Read customers | See the customer list, the customer records and their activity log. |
| Manage customers | Edit customer details. |
| Block and unblock customers | Block a customer, with an internal note, and unblock them. |
| Change customer passwords | Set a new password for a registered customer. |
| Manage refunds and store credit | Refund orders, manage refunds, and issue, edit and void store credit. |
| Manage payment links and instructions | Send payment instructions and Stripe payment links. |
| Issue invoices and credit notes | Generate invoices and credit notes, reconcile them and mark them as failed. |
| Read promotions | See the promotions and their usage. |
| Manage promotions | Create, edit, activate, deactivate and delete promotions. |

> [!TIP]
>
> When a person can read a screen but not change it, the module shows a notice such as "You can view these settings,
> but you do not have permission to change them." and hides the buttons that need the missing permission.

## Storefront API

Your storefront server uses the storefront API to list products, categories and collections, run the cart and the
checkout, start Stripe payments, and handle the customer accounts. Every request carries the token from the
[API](https://strapi-suite.littlebox.pt/backend/guides/ecommerce/settings.md#api) tab and a checkout session, and the browser never calls the API directly. See the
[frontend guide](https://strapi-suite.littlebox.pt/frontend/guides/ecommerce/overview.md) to connect your storefront.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.