commercetools connector - Fulfilment Updates
Feature
Changed on:
30 Jan 2024
Overview
Fulfilment updates are done at the Order Item level. Where each item can have a specific fulfilment status or multiple items can have the same fulfilment status.How it Works
The first stage validates the signature and checks the content has the required parameters. If all goes well, the request is added to the internal message queue to be processed asynchronously otherwise connector 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 commercetools-connector.Partners utilize the same approach by adding their own handlers and enabling the processing of different messages that are specific to their end goals.All webhooks carry minimal information and require commercetools-connector 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 commercetools or using it to drive extra logic.Fulfilment Status
Once Fulfilment is created at fluent it sends the webhook with some custom data along with other details like fulfilment status to update the Fulfilment status at commercetools.Below are the custom fields at commercetools :
| Fluent Fulfilment Metadata Fields | Description |
| flFulfilment | Fluent Fulfilment Group Key |
| flFulfilmentMetadata | Fluent Fulfilment Metadata |
| flFulfilmentMetadata.fulfilmentId | Fulfilment Id |
| flFulfilmentMetadata.fulfilmentLocationRef | Fulfilment Location Ref |
| flFulfilmentMetadata.fulfilmentLocationName | Fulfilment Location Name |
| flFulfilmentMetadata.fulfilmentStatus | Fulfilment Status |
| flFulfilmentMetadata.fulfilmentQty | Fulfilment Quantity |
| flFulfilmentMetadata.ctStatus | commercetools Status |
| commercetools Fields | Fluent Fields |
| Product SKU | Product Ref |
| Line Item State | Fulfilment Status |
| Qty | Filled Quantity |
| Fulfilment Metadata [{"fulfilmentStatus":"picking","fulfilmentQty":"86","fulfilmentId":"300","fulfilmentLocationRef":"LOC_SYDS"," fulfilmentLocationName":"Sydney Store" }] | Fulfilment Data |
As shown in the above snapshot, There are two fulfilments one with id (Fulfilment - 616) for the product “Down jacket “Rapdi“ Peuterey black Gir“ and “Sweater Better Rich grey“. The second fulfilment with id (Fulfilment - 617) will be for only “Sweater Better Rich grey”.
Now the info will be sent to commercetools and in commercetools the fulfilment data will be mapped against the Order item ie. For the product “Sweater Better Rich grey” there will be two fulfilment details. Please refer above snapshot.Fulfilment Query
1query GetFulfilmentById($fulfilmentId: ID!) {
2 fulfilmentById(id: $fulfilmentId) {
3 id
4 ref
5 status
6 type
7 order {
8 id
9 ref
10 }
11 fromAddress {
12 ref
13 name
14 }
15 items(first: 500) {
16 fulfilmentItemEdges: edges {
17 fulfilmentItemNode: node {
18 id
19 ref
20 status
21 requestedQuantity
22 filledQuantity
23 rejectedQuantity
24 orderItem {
25 id
26 ref
27 product {
28 name
29 }
30 status
31 quantity
32 }
33 }
34 }
35 }
36 }
37}Fluent Webhook: Fulfilment payload
The below payload will be pushed to the internal queue.1{
2 "id": "c321a113-9307-4269-9a91-a2f99cefe07b",
3 "name": "fc.connect.order.webhook.fulfilment-status-update",
4 "accountId": "CNCTDEV",
5 "retailerId": "1",
6 "rootEntityId": "127",
7 "rootEntityType": "ORDER",
8 "rootEntityRef": "CC_G_FROM_POSTMAN_929",
9 "entityId": "91",
10 "entityRef": "cf45b633-d91a-4eb2-84c9-36495dd3fec3",
11 "entityType": "FULFILMENT",
12 "entityStatus": "AWAITING_WAVE",
13 "type": "NORMAL",
14 "attributes": {}
15}