Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

Walmart v3 Ship Order Lines

See more Walmart v3 Examples

Updates the status of order lines to Shipped and trigger the charge to the customer. The response to a successful call contains the order with the shipped line items.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oJson
LOCAL nOrderLineIndex
LOCAL nStatusIndex
LOCAL oResp
LOCAL cLineNumber
LOCAL cProductName
LOCAL cSku
LOCAL cUnitOfMeasurement
LOCAL cAmount
LOCAL nStatusDate
LOCAL nCount_j
LOCAL cChargeType
LOCAL cChargeName
LOCAL cV_Currency
LOCAL nChargeAmountAmount
LOCAL cTaxName
LOCAL cTaxAmountCurrency
LOCAL cTaxAmountAmount
LOCAL cStatus
LOCAL cStatusQuantityUnitOfMeasurement
LOCAL cStatusQuantityAmount
LOCAL nShipDateTime
LOCAL cCarrier
LOCAL cTrackingInfoMethodCode
LOCAL cTrackingNumber
LOCAL cTrackingURL
LOCAL cReturnCenterAddressName
LOCAL cReturnCenterAddressAddress1
LOCAL cReturnCenterAddressCity
LOCAL cReturnCenterAddressState
LOCAL cReturnCenterAddressPostalCode
LOCAL cReturnCenterAddressCountry
LOCAL cDayPhone
LOCAL cEmailId
LOCAL cPurchaseOrderId
LOCAL cCustomerOrderId
LOCAL cSellerOrderId
LOCAL cCustomerEmailId
LOCAL nOrderDate
LOCAL cPhone
LOCAL nEstimatedDeliveryDate
LOCAL nEstimatedShipDate
LOCAL cMethodCode
LOCAL cName
LOCAL cAddress1
LOCAL cCity
LOCAL cState
LOCAL cPostalCode
LOCAL cCountry
LOCAL cAddressType
LOCAL i
LOCAL j
LOCAL nCount_i

nSuccess := 0

//  This example assumes the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oHttp := CreateObject("Chilkat.Http")

oHttp:SetRequestHeader("WM_QOS.CORRELATION_ID", "b3261d2d-028a-4ef7-8602-633c23200af6")
oHttp:SetRequestHeader("WM_SEC.ACCESS_TOKEN", "eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....")
oHttp:SetRequestHeader("Accept", "application/json")
oHttp:SetRequestHeader("WM_SVC.NAME", "Walmart Marketplace")

//  Send the following in the request body:

//  {
//    "orderShipment": {
//      "orderLines": {
//        "orderLine": [
//          {
//            "lineNumber": "1",
//            "intentToCancelOverride": false,
//            "sellerOrderId": "92344",
//            "orderLineStatuses": {
//              "orderLineStatus": [
//                {
//                  "status": "Shipped",
//                  "statusQuantity": {
//                    "unitOfMeasurement": "EACH",
//                    "amount": "1"
//                  },
//                  "trackingInfo": {
//                    "shipDateTime": 1580821866000,
//                    "carrierName": {
//                      "carrier": "UPS"
//                    },
//                    "methodCode": "Standard",
//                    "trackingNumber": "22344",
//                    "trackingURL": "http://walmart/tracking/ups?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92345"
//                  },
//                  "returnCenterAddress": {
//                    "name": "walmart",
//                    "address1": "walmart store 2",
//                    "city": "Huntsville",
//                    "state": "AL",
//                    "postalCode": "35805",
//                    "country": "USA",
//                    "dayPhone": "12344",
//                    "emailId": "walmart@walmart.com"
//                  }
//                }
//              ]
//            }
//          },
//          {
//            "lineNumber": "2",
//            "sellerOrderId": "92344",
//            "orderLineStatuses": {
//              "orderLineStatus": [
//                {
//                  "status": "Shipped",
//                  "statusQuantity": {
//                    "unitOfMeasurement": "EACH",
//                    "amount": "1"
//                  },
//                  "trackingInfo": {
//                    "shipDateTime": 1580821866000,
//                    "carrierName": {
//                      "carrier": "FedEx"
//                    },
//                    "methodCode": "Express",
//                    "trackingNumber": "22344",
//                    "trackingURL": "http://walmart/tracking/fedEx?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92344"
//                  },
//                  "returnCenterAddress": {
//                    "name": "walmart",
//                    "address1": "walmart store 2",
//                    "city": "Huntsville",
//                    "state": "AL",
//                    "postalCode": "35805",
//                    "country": "USA",
//                    "dayPhone": "12344",
//                    "emailId": "walmart@walmart.com"
//                  }
//                }
//              ]
//            }
//          }
//        ]
//      }
//    }
//  }

oJson := CreateObject("Chilkat.JsonObject")
nOrderLineIndex := 0
nStatusIndex := 0
oJson:I := nOrderLineIndex
oJson:J := nStatusIndex
oJson:UpdateString("orderShipment.orderLines.orderLine[i].lineNumber", "1")
oJson:UpdateBool("orderShipment.orderLines.orderLine[i].intentToCancelOverride", 0)
oJson:UpdateString("orderShipment.orderLines.orderLine[i].sellerOrderId", "92344")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status", "Shipped")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement", "EACH")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount", "1")
oJson:UpdateInt("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime", 123)
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier", "UPS")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode", "Standard")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber", "22344")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL", "http://walmart/tracking/ups?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92345")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name", "walmart")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1", "walmart store 2")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city", "Huntsville")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state", "AL")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode", "35805")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country", "USA")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone", "12344")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId", "walmart@walmart.com")

nOrderLineIndex := nOrderLineIndex + 1
nStatusIndex := 0
oJson:I := nOrderLineIndex
oJson:J := nStatusIndex
oJson:UpdateString("orderShipment.orderLines.orderLine[i].lineNumber", "2")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].sellerOrderId", "92344")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status", "Shipped")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement", "EACH")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount", "1")
oJson:UpdateInt("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime", 123)
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier", "FedEx")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode", "Express")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber", "22344")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL", "http://walmart/tracking/fedEx?&type=MP&seller_id=12345&promise_date=03/02/2020&dzip=92840&tracking_numbers=92344")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name", "walmart")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1", "walmart store 2")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city", "Huntsville")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state", "AL")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode", "35805")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country", "USA")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone", "12344")
oJson:UpdateString("orderShipment.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId", "walmart@walmart.com")

oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpJson("POST", "https://api-gateway.walmart.com/v3/orders/{purchaseOrderId}/shipping", oJson, "application/json", oResp)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oJson:destroy()
    oResp:destroy()
    RETURN
ENDIF

? "Response status code: " + Str(oResp:StatusCode)

oResp:GetBodyJson(oJson)

//  A sample JSON response:

//  {
//    "order": {
//      "purchaseOrderId": "1234567891234",
//      "customerOrderId": "9876543212345",
//      "sellerOrderId": "13233454564657",
//      "customerEmailId": "customer@walmartlabs.com",
//      "orderDate": 1478284060000,
//      "shippingInfo": {
//        "phone": "6501234567",
//        "estimatedDeliveryDate": 1479798000000,
//        "estimatedShipDate": 1478674800000,
//        "methodCode": "Value",
//        "postalAddress": {
//          "name": "Jane Doe",
//          "address1": "123 Main street",
//          "city": "Sunnyvale",
//          "state": "CA",
//          "postalCode": "94086",
//          "country": "USA",
//          "addressType": "OFFICE"
//        }
//      },
//      "orderLines": {
//        "orderLine": [
//          {
//            "lineNumber": "1",
//            "item": {
//              "productName": "Kenmore CF-1 or 20-86883 Canister Secondary Filter Generic 2 Pack",
//              "sku": "wei-ASSET-675gku675"
//            },
//            "charges": {
//              "charge": [
//                {
//                  "chargeType": "PRODUCT",
//                  "chargeName": "ItemPrice",
//                  "chargeAmount": {
//                    "currency": "USD",
//                    "amount": 555
//                  },
//                  "tax": {
//                    "taxName": "Tax1",
//                    "taxAmount": {
//                      "currency": "USD",
//                      "amount": 48.56
//                    }
//                  }
//                }
//              ]
//            },
//            "orderLineQuantity": {
//              "unitOfMeasurement": "EACH",
//              "amount": "1"
//            },
//            "statusDate": 1478297929000,
//            "orderLineStatuses": {
//              "orderLineStatus": [
//                {
//                  "status": "Shipped",
//                  "statusQuantity": {
//                    "unitOfMeasurement": "EACH",
//                    "amount": "1"
//                  },
//                  "trackingInfo": {
//                    "shipDateTime": 1438163400000,
//                    "carrierName": {
//                      "carrier": "FedEx"
//                    },
//                    "methodCode": "Value",
//                    "trackingNumber": "911001572321619861",
//                    "trackingURL": "http://www.fedex.com/Tracking?action=track=english=us=x=911001572321619861"
//                  },
//                  "returnCenterAddress": {
//                    "name": "ABC",
//                    "address1": "123 Bridge street",
//                    "city": "Huntsville",
//                    "state": "AL",
//                    "postalCode": "35805",
//                    "country": "USA",
//                    "dayPhone": "6501234567",
//                    "emailId": "RCemailaddress@company.com"
//                  }
//                }
//              ]
//            }
//          }
//        ]
//      }
//    }
//  }

oJson:EmitCompact := 0
? "Response JSON:"
? oJson:Emit()

//  Insert code here to load the above JSON into the json object.

cPurchaseOrderId := oJson:StringOf("order.purchaseOrderId")
cCustomerOrderId := oJson:StringOf("order.customerOrderId")
cSellerOrderId := oJson:StringOf("order.sellerOrderId")
cCustomerEmailId := oJson:StringOf("order.customerEmailId")
nOrderDate := oJson:IntOf("order.orderDate")
cPhone := oJson:StringOf("order.shippingInfo.phone")
nEstimatedDeliveryDate := oJson:IntOf("order.shippingInfo.estimatedDeliveryDate")
nEstimatedShipDate := oJson:IntOf("order.shippingInfo.estimatedShipDate")
cMethodCode := oJson:StringOf("order.shippingInfo.methodCode")
cName := oJson:StringOf("order.shippingInfo.postalAddress.name")
cAddress1 := oJson:StringOf("order.shippingInfo.postalAddress.address1")
cCity := oJson:StringOf("order.shippingInfo.postalAddress.city")
cState := oJson:StringOf("order.shippingInfo.postalAddress.state")
cPostalCode := oJson:StringOf("order.shippingInfo.postalAddress.postalCode")
cCountry := oJson:StringOf("order.shippingInfo.postalAddress.country")
cAddressType := oJson:StringOf("order.shippingInfo.postalAddress.addressType")
i := 0
j := 0
nCount_i := oJson:SizeOfArray("order.orderLines.orderLine")
DO WHILE i < nCount_i
    oJson:I := i
    cLineNumber := oJson:StringOf("order.orderLines.orderLine[i].lineNumber")
    cProductName := oJson:StringOf("order.orderLines.orderLine[i].item.productName")
    cSku := oJson:StringOf("order.orderLines.orderLine[i].item.sku")
    cUnitOfMeasurement := oJson:StringOf("order.orderLines.orderLine[i].orderLineQuantity.unitOfMeasurement")
    cAmount := oJson:StringOf("order.orderLines.orderLine[i].orderLineQuantity.amount")
    nStatusDate := oJson:IntOf("order.orderLines.orderLine[i].statusDate")
    j := 0
    nCount_j := oJson:SizeOfArray("order.orderLines.orderLine[i].charges.charge")
    DO WHILE j < nCount_j
        oJson:J := j
        cChargeType := oJson:StringOf("order.orderLines.orderLine[i].charges.charge[j].chargeType")
        cChargeName := oJson:StringOf("order.orderLines.orderLine[i].charges.charge[j].chargeName")
        cV_Currency := oJson:StringOf("order.orderLines.orderLine[i].charges.charge[j].chargeAmount.currency")
        nChargeAmountAmount := oJson:IntOf("order.orderLines.orderLine[i].charges.charge[j].chargeAmount.amount")
        cTaxName := oJson:StringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxName")
        cTaxAmountCurrency := oJson:StringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.currency")
        cTaxAmountAmount := oJson:StringOf("order.orderLines.orderLine[i].charges.charge[j].tax.taxAmount.amount")
        j := j + 1
    ENDDO
    j := 0
    nCount_j := oJson:SizeOfArray("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus")
    DO WHILE j < nCount_j
        oJson:J := j
        cStatus := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].status")
        cStatusQuantityUnitOfMeasurement := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.unitOfMeasurement")
        cStatusQuantityAmount := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].statusQuantity.amount")
        nShipDateTime := oJson:IntOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.shipDateTime")
        cCarrier := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.carrierName.carrier")
        cTrackingInfoMethodCode := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.methodCode")
        cTrackingNumber := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingNumber")
        cTrackingURL := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].trackingInfo.trackingURL")
        cReturnCenterAddressName := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.name")
        cReturnCenterAddressAddress1 := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.address1")
        cReturnCenterAddressCity := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.city")
        cReturnCenterAddressState := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.state")
        cReturnCenterAddressPostalCode := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.postalCode")
        cReturnCenterAddressCountry := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.country")
        cDayPhone := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.dayPhone")
        cEmailId := oJson:StringOf("order.orderLines.orderLine[i].orderLineStatuses.orderLineStatus[j].returnCenterAddress.emailId")
        j := j + 1
    ENDDO
    i := i + 1
ENDDO

oHttp:destroy()
oJson:destroy()
oResp:destroy()