Order Tracking

The guide illustrates the Order Tracking strategy adopted on Shopware

Problem statement

The order tracking code(s) needs to be updated to the respective orders on Shopware. In this guide, the tracking code(s) are received through an XML file on the Filesystem but it can be any external endpoint.

Strategy

The order tracking is a two-step process, a single incoming connection will be branched to two routes that perform the following operations,

  1. Route-1: Update the order and shipping status of the order.
  2. Route-2: Update the Tracking code for the respective order.

Sample Input file

<?xml version="1.0"?>
<Orders xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Order>
<OrderNumber>16303</OrderNumber>
<CustomerNum>230XXXNX</CustomerNum>
<Name>CarXXXX PhiXXXXX</Name>
<deliveryStatus>true</deliveryStatus>
<Shipment>
<ShippingDate>2019-12-30</ShippingDate>
<CarrierCode>DHL</CarrierCode>
<CarrierDescr>DHL</CarrierDescr>
<CarrierProductCode>10</CarrierProductCode>
<CarrierProductDescr>Next day BeXXXX, oveXXXXnfXXXm sXXXXa</CarrierProductDescr>
<TrackingURL>https://www.dhlparcel.nl/nl/paXXXXXXXXXXXXXXXXX&AB=AJ1000001111<TrackingURL/>
<AirwayBill>AJ1000001111<AirwayBill/>
</Shipment>
</Order>
</Orders>

Important Transformations

How to get OrderId from OrderNumber

A Merger Transformer with an HTTP call to the Orders search API with the following filter condition will fetch the respective OrderId from Shopware.

How to fetch the Order Delivery Id (Tracking id)

A merger transformer that utilizes the OrderId found in the previous transformer to fetch the respective Order delivery id or Tracking id.

The configuration is as shown below,

Incoming Connection


Route-1: Update the order and shipping status of the order

Strategy and Shopware API calls

The strategy adopted to update the order and shipping status is,

  1. Determine the OrderId and TrackingId using the previously mentioned transformers.
  2. Invoke the following API calls in the order specified to perform state changes.
1. Change the Order status to inprocess
/api/v2/_action/order/&{orderId}/state/process

2. Change the shipping status to Shipped
/api/v2/_action/order_delivery/&{tracking.id}/state/ship

3. Change the Order status to Done
/api/v2/_action/order/&{orderId}/state/complete

Route Configuration

Outgoing Configurations


Route-2: Update the Tracking code for the respective order

The strategy adopted to update the Tacking code for an order is as follows,

  1. Determine the OrderId and TrackingId using the previously mentioned transformers.
  2. Invoke the order-deliveries API call to update the Tracking code for the Order.
Update the tracking code

/api/v2/order-delivery/&{tracking.id}

Sample Payload

{
"tracking":{
"id" : "294c2dXXXXXXXXXXXXXXXXXXXXXXXX"
}.
   "trackingCodes": [
       "https://www.dhlparcel.nl/nl/paXXXXXXXXXXXXXXXXX&AB=AJ1000001111"
   ]
}

Route Configuration

Outgoing Configuration