Changed on:
17 Oct 2023
The Order module is responsible for exporting orders to Fluent and receiving order updates.
Key Features:
Limitations:
Adobe’s Commerce native message queue was used to export orders. Once an order is saved the system triggers the
`sales_order_save_after event`
`FluentConnector\Order\Observer\PublishOrderToExportQueue`
`FluentConnector\Order\Model\ConfigProvider`
If there is a need to customize when an order is considered ready to be sent to Fluent - ConfigProvider class should be rewritten in DI configuration. To validate order has not been published before the extension tracks when orders are exported through extension attributes: order.extension_attributes.fluent.publish_status should be empty or equal to 0. When an order is ready to be exported then it is added to the message queue with the topic name of fluentcommerce.order.publisher.
Adding order to the export queue contains a few steps:
The order exporting process flow :
Exporting logic:
Webhook processing happens in 2 stages.
The first stage does the validation of the signature and checks the content has the required parameters. If all goes well, the request is added to the message queue to be processed asynchronously otherwise Adobe will return an error to Fluent to signal that it was unable to accept the request.
The second stage is the actual processing of the webhook message. The message name is key to drive, how the message is going to be processed as these are mapped to internal handlers in Adobe.
`1 <type name="FluentConnector\General\Api\WebHook\HandlerFactoryInterface"> 2 <arguments> 3 <argument name="handlers" xsi:type="array"> 4 <item name="OrderStatusChanged" xsi:type="string">FluentConnector\Order\Handler\OrderStatusUpdateHandler</item> 5 </argument> 6 </arguments> 7 </type>`
Other modules utilize the same approach by adding their own handlers and enabling the processing of different messages that are specific to their modules.
All webhook carry minimal information and required Adobe to fetch extra details from Fluent in order to complete processing the message received. The diagram below represents the flow executed for an order status update message. It is possible to override certain parts of the code and extend its functionality. For example, fetching more details from Fluent and either saving it in Adobe or using it to drive extra logic. There are some events that can be leveraged to achieve this but if the events aren’t enough Adobe’s Commerce dependency injection is the recommended way.
Name | Description | Parameters |
fluent_order_push_before | Event before the order is pushed to Fluent | order of type OrderInterface |
fluent_order_push_after | Event after the order is successfully pushed to Fluent | order of type OrderInterface |
fluent_order_push_prepare_simple_payload_after | Allows customisation of an order line containing a simple product | payload of type array |
fluent_order_push_prepare_configurable_payload_after | Allows customisation of an order line containing a configurable product | payload of type array order_item of type OrderItemInterface |
fluent_order_push_prepare_fulfilment_choice_payload_after | Allows customisation of the fulfilment choice properties | fulfilment of type array request_data of type PushOrderDataRequestInterface |
fluent_order_push_prepare_order_payload_after | Allows customisation of order level properties | order of type OrderInterface payload of type PushOrderDataRequestInterface |
fluent_order_push_query_build_after | Allows customisation of order mutation query | query of type string |
Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.