Creating a new order and payment status

We will explain how you can create your own order or payment status and link it to an email template.

Before you start

We recommend that you use Adminer to work on the database
Making a backup before you start is always a smart thing to do, just to be safe in case that things go wrong.

Getting the right id's

First we need to make sure that we use the right id's for the order and payment status that we are adding.
These id's are found in the database in the table state_machine.

Click on Select data (1) to see the entries.

Use the id found next to order_delivery.state (1) if you want to add an delivery status.
Use the id found next to order_transaction.state (2) if you want to add an payment status.
Use the id found next to order.state (3) if you want to add an order status.

We need the id DA86D74FE395431ABFB261723AEB5D14 to add the a payment status and id DC61061A3634414ABB584FD50B94BBD3 since we are adding order status.

Create status

Now that we have the id's that we need we can create the status, this is done in the table state_maschine_state.

With New item (1) you insert a new record into the table. This should bring up the following window.

  • id (1) here you enter a free md5 hash id for your new data set, you can use https://www.md5hashgenerator.com/ to generate an id.
  • technical_name (2) is the name of your new entry.
  • state_machine_id (3) is the id of the transaction. These are the id's that we already looked up in the table state_machine.
    In this case it's the id DA86D74FE395431ABFB261723AEB5D14 for the a payment status and id DC61061A3634414ABB584FD50B94BBD3 for the order status.
  • created_at (4) shows the date and time when this entry was added, set it to now.
  • updated_at (5) shows the time and date that it was updated, set this to NULL.
  • save (6) click this once you are done to store the entry in the database.

If all entries are valid you should notice the message below.

Please note that you need the id's from both entries that you just created, in this case I created FA8C0650F5500FA89A33C2EF27D8D4B6 for the new payment status and AE3FDA7F48574C2797336515FC8D42C2 for the new order status.

Next you have to go to the table language to look-up the right language id's.

We will need to add the translations for English and German.

It's important that you check the id's that your system uses.

The English id is 2FBB5FE2E29A4D70AA5854CE7CE3E20B and the German is F4231401022B473285FE0BAAB078C46E.

Next you have to go to the table state_machine_state_translation to create the translations for your process.

  • language_id (1) Use the id's that you looked up, 2FBB5FE2E29A4D70AA5854CE7CE3E20B for English and F4231401022B473285FE0BAAB078C46E for German.
  • state_machine_state_id (2) enter the id's that you created FA8C0650F5500FA89A33C2EF27D8D4B6 for the payment status and FA8C0650F5500FA89A33C2EF27D8D4B6 for orders status.
  • name (3) Here you can enter the name that is shown in the Admin area.
  • custom_fields (4) Can be left empty.
  • created_at (5) Shows the date and time when this entry was added, set it to now.
  • updated_at (6) Shows the time and date that it was updated, set this to NULL.
  • save (7) Click this once you are done to store the entry in the database.

Please note that you will need to do this for all languages that you are using, in this case I added English and German for both new status. 

Workflow / Transition

Since Shopware 6 specifies which status can be changed in which way and thus, for example, the status "open" cannot be changed directly to "completed", you must now also set this up for your new transaction.

I order to find the right id's open the table state_machine_state, In my example I will add my new oder status after the order status open so this is the id we want.
As you can see we have multiple entries (1) that are called open, to find the right one that matches the order process we can click on the state_machine_id (2).

Here we can see that the technical_name is order.state so this entry we need, go back to the last page and write down the id found in the column id, in this case it would be 1EEA2C93100C4770B561CA02FB195FF0.

To setup your new transaction, go to the table state_machine_transition and insert a new data record there.

  • id (1) Here you enter a free md5 id for your new data set, you can use https://www.md5hashgenerator.com/ to generate an id.
  • action_name (2) Give you action a name.
  • state_machine_id (3) you enter the state_machine_id belonging to your process.
    In this case we are adding the new order status so the id would be DC61061A3634414ABB584FD50B94BBD3.
  • from_state_id (4) you enter the state_machine_state_id of the process from which you want to switch to another process.
    We want our new order status to be available for order that have the curent status open, so we are using the id DC61061A3634414ABB584FD50B94BBD3.
  • to_state_id (5) Here we will enter the id (AE3FDA7F48574C2797336515FC8D42C2) for the new order status that we created a few steps back, this id can be found in the table state_machine_state in column id.
  • custom_fields (6) Can be left empty.
  • created_at (7) Shows the date and time when this entry was added, set it to now.
  • updated_at (8) Shows the time and date that it was updated, set this to NULL.
  • save (9) Click this once you are done to store the entry in the database.

Admin view

After you have set up your new process as described above, it will be displayed in your selected category in the Admin and can be selected as you have previously configured.

Create an email template

The status is created, now you still have to create an email template for it.
Um die E-Mail_Vorlage zu erstellen, gehst Du auf Einstellungen > E-Mail-Templates > Erstellen.

  • Type (1) allows you to choose between different e-mail types for the standard processes, here it is advisable to select one that is similar to the one you have created yourself.
  • Describe (2) the actual process for which the email template is intended.
  • Options (3) Here you can add the subject and the sender of the e-mail.
  • Attachments (4) Here you can add attachments to the email.
  • Bei dem Punkt Mail-Text (5) gibst Du den von Dir gewünschten Inhalt der E-Mail an. 

Create flow

Finally, you need to create an action for our new email template in the Flow Builder. To do this, go to Settings > Flow Builder > Add Flow.

  • Name (1) Name you flow.
  • Description (2) Give your flow a description.
  • Priotiy (3) Use this to set a priority.
  • Active (4) Make sure that you have activated the flow.
  • Next, under Flow, select the trigger (1) through which the event is to be triggered. In this case, you then select your new process.

Then add an action and select Send email as the action.

  • Recipients (2) allows you to select who should receive the email when the flow is triggered.
  • Email template (3) select the e-mail template you have previously created for your new process.
  • Add documents (4) allows you to add another document such as an invoice, etc. Please make sure that the Flow Builder generates the documents that you wish to add first.

After you have saved the action, your process should be fully set up and selectable and functional in the Storefront and Admin.

Was this article helpful?