Local orders ¶
You can display user orders even if the shop is not connected to an ERP system.
The user sees the orders stored locally in the shop. Order history shows only documents of type orders
.
Because the shop only has local data for orders, the available document types are different.
The use of the local documents is enabled with the use_local_documents
configuration parameter:
1 |
|
The feature uses event listeners, so the standard logic does not change if this value is set to false.
Ibexa Commerce offers an event listener which uses the ConfigurationEvents::READ_CONFIGURATION
event.
This listener is disabled by default, so you need to activate it in your project:
1 |
|
If local documents are used (parameter use_local_documents == true
), the logic checks if the requested message is OrderListMessage
or OrderListMessage
.
If so, it throws an exception UseLocalDocumentsException
that is caught by the exception event.
The system then creates the same response as is sent by ERP (the response contains the same information as if it were using ERP.)
UseLocalDocumentsListener¶
Listener onRequestEvent
¶
If there is no connection with ERP and local documents are used,
the listener throws an exception that stops sending the message to ERP.
When the exception is caught, another event (MessageExceptionEvent
) is dispatched and the onExceptionMessage
listener is executed.
1 2 3 4 5 |
|
Listener onExceptionMessage
¶
Checks the exception that is thrown by the previous listener and creates a ResponseDocument
filled with local data (orders).
The response has the same structure as if it was returned from ERP, so no additional changes in the template are required.
1 2 3 4 5 |
|
silver.orderhistory/src/Siso/Bundle/OrderHistoryBundle/EventListener/UseLocalDocumentsListener.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Generating an invoice¶
For information about generating a PDF invoice from a local order, see Local order process.
SisoLocalOrderManagementBundle
handles orders without an ERP connection.
The bundle generates:
- local orders with an invoice
- invoice entity (special implementation to generate the invoice number)
- invoice view
- invoice PDF and attaches it to an email
Show invoice in order history¶
Once the local order with the invoice is generated you can show it in order history:
Local invoices are available only for the current user (nobody else has access to the invoice page).
Order history details contain a link in the header to the invoice page:
Order history list¶
To show the invoice link in a new column of the table, override the configuration.
1 2 3 4 |
|
A new Twig block shows the new link to the invoice if the invoice number is set.
1 2 3 4 5 6 7 |
|
Order history detail¶
To show the link to the invoice in the detail page modify the Twig template.
Order history page¶
Only the owner of the basket can access the InvoiceController
controller that displays the invoice.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Templates¶
EshopBundle/Resources/views/Invoice/show.html.twig
template is used to generated the invoice view and the invoice PDF.
This template does not extend any other template, so it also generates the <html>
and <head>
tags.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|