When mapping an order, we must define the path to create the data object to send an order to a remote API. We use a method named Dot Notation.
What is Dot Notation?
Dot Notation is one way to access a property of an object. To use dot notation, write the name of the object, followed by a dot (.), followed by the name of the property.
The WP Data Sync API extends Dot Notation with [i]
to create the items for our request body.
Path Mapping
Path mapping is done by using the object keys. The correct format should be provided in your remote API documentation.
Since a single order can contain multiple items. There are 2 methods to map items for an order.
Path Mapping Methods
Multiple Item Request
A multiple item request sends all items in a single request.
Example: Multiple Item Request Object
{
"Order": {
"FullName": "Shipping Full Name",
"Address": "123 E Main St",
"City": "Scottsdale",
"State": "AZ",
"Zip": "85250",
"Company": "WP Data Sync",
"Items": [
{
"ProductName": "Product Name",
"ProductID": 121,
"Quantity": 1,
"Price": "12.66",
"ShippingMethod": "Standard Shipping"
},
{
"ProductName": "Product Name 2",
"ProductID": 1234,
"Quantity": 1,
"Price": "17.66",
"ShippingMethod": "Standard Shipping"
}
]
}
}
Paths for example multiple item request object
- Order.FullName
- Order.Address
- Order.City
- Order.State
- Order.Zip
- Order.Company
- Order.Items.[i].ProductName
- Order.Items.[i].ProductID
- Order.Items.[i].Quantity
- Order.Items.[i].Price
- Order.Items.[i].ShippingMethod
NOTE: The [i]
notation is used to define an item object. This instructs the WPDS API to create an item object for each item in the order.
Single Item Request
A single item request sends one item in multiple requests.
Example: Single Item Request Object
Each of the 2 item objects will be sent in a separate request.
{
"FullName": "Shipping Full Name",
"Address": "123 E Main St",
"City": "Scottsdale",
"State": "AZ",
"Zip": "85250",
"Company": "WP Data Sync",
"Item": {
"productName": "Items - Product Name",
"productID": 121,
"quantity": 1,
"price": "12.66",
"shippingMethod": "Standard Shipping"
}
},
{
"FullName": "Shipping Full Name",
"Address": "123 E Main St",
"City": "Scottsdale",
"State": "AZ",
"Zip": "85250",
"Company": "WP Data Sync",
"Item": {
"productName": "Items - Product Name 2",
"productID": 1234,
"quantity": 1,
"price": "17.66",
"shippingMethod": "Standard Shipping"
}
}
Paths for example single item request object
- [i].FullName
- [i].Address
- [i].City
- [i].State
- [i].Zip
- [i].Company
- [i].Item.ProductName
- [i].Item.ProductID
- [i].Item.Quantity
- [i].Item.Price
- [i].Item.ShippingMethod
Order Mapping UI
Create the order map paths in the easy to use order mapping UI. See the screenshot below for an example. Once your paths are saved. You can use the request test feature to check for the correct order object format.