Depending on the chosen payment method, the order is completed after:
- submitting the order summary
- receiving a notification from the payment gateway
- returning from the payment gateway
During completion, order data is sent to the ERP system. On success, the state of the submitted basket changes to
If it fails, the state becomes
ordered_failed and an email is sent to administrator.
After the summary of the checkout is confirmed by the user, the payment process is initiated.
To identify the order across all systems (shop, payment gateway, ERP system), a GUID is generated and stored to the basket.
The generation of that ID is left to the
BasketGuidService service (service ID
This way it is easy to override the standard generation routine.
AbstractErpService defines the
submitOrder(Basket $basket) method
The standard implementation of this method is found in
This method prepares the
CreateSalesOrderMessage out of the basket's data and sends it to the ERP using ERP transport.
In case of an error during remote communication the failed order process is triggered using
Event before order is submitted¶
Before the order is sent to the ERP an event is triggered.
The corresponding event listener can modify the basket data or perform any additional action.
It can set the status to
failed and set en error message.
If the event status is
failed, the order is not submitted and is treated as a lost order.
It is not possible to use services in appropriate event listeners that require the session, because the process can also be executed from the command line in the lost order process.
For example it is not possible to use the
ses.customer_profile_data.ez_erp), and the Repository (
ezpublish.api.repository) must be used instead in order to fetch the user data.
Sending additional data in the order¶
You can extend the message with additional fields in two ways:
- Extend the
CreateSalesOrderMessageclass. This solution requires maintenance effort in case of an update of the shop's base implementation, as changes to the base message must be merged to the extended version.
- Write the data into one of the SesExtension tree elements (see
ses_treein table)). This solution should only be used to add simple, single-valued fields. During the communication with the remote service (e.g. Web.Connector), the tree attributes are mapped between PHP arrays and XML data implicitly without any structure definition. This can cause conflicts for XML elements that occur multiple times, and sequential PHP arrays.
Sometimes it is necessary to send additional project-specific data in the order.
If you need to send the data to ERP, you can get it from basket (
dataMap) or from customer data.
In such a case, implement an event listener which subscribes to
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
1 2 3 4 5