Customers and orders

    Get a customer's list of orders

    Get a customer's list of orders.

    Request

    • Method: GET
    • Version: v3, this API call supports additional sort and filter mechanisms as well as retrieving only a sub-set of fields

      Note: In order to access the v3 API endpoints please make sure you have enabled the new rendering engine.

    • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
      • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
    • Path: /webresources/api/v3/sites/current/customers/[customer_ID]/orders
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    The details for the specified customer ID in JSON format.

    • assignedUserId - (integer)
    • categoryId - (integer)
    • countryCode - (string)
    • createDate - (dateTime) - the date must be in this format - 2014-09-03T07:00:00
    • cycleTypeId - (integer)
      • 1 - Once
      • 2 - Daily
      • 3 - Weekly
      • 4 - Fortnightly
      • 5 - Monthly
      • 6 - Quarterly
      • 7 - Half Yearly
      • 8 - Yearly
    • destinationAddressIsResidential - (boolean)
    • directDebitDays - (integer)
    • directDebitProcessed - (boolean)
    • directDebitTypeId - (integer)
      • 1 - Credit card
      • 2 - Direct debit
    • discountCodeId - (integer)
    • discountRate - (integer)
    • endRecurDate - (dateTime) - the date must be in this format - 2014-09-03T07:00:00
    • entityId - (integer)
    • giftVoucherAmount - (integer)
    • giftVoucherId - (integer)
    • id - (integer)
    • integrationId - (integer)
    • invoiceDate - (dateTime) - the date must be in this format - 2014-09-03T07:00:00
    • invoiceNumber - (string)
    • invoiced - (boolean)
    • isIntermediate - (boolean)
    • lastUpdateDate - (dateTime) - the date must be in this format - 2014-09-03T07:00:00
    • name - (string)
    • nextInvoiceDate - (dateTime) - the date must be in this format - 2014-09-03T07:00:00
    • parentId - (integer)
    • paymentMethodTypeId - (integer)
      • 1 - Credit card
      • 2 - Check
      • 3 - Cash
      • 4 - EFT
    • quote - (boolean)
    • recur - (boolean)
    • shippingAttention - (string)
    • shippingDescription - (string)
    • shippingInstructions - (string)
    • shippingOptionId - (integer)
    • shippingPrice - (integer)
    • shippingRateKey - (string)
    • shippingTaxRate - (integer)
    • siteId - (integer)
    • statusTypeId - (integer)
    • taxCodeId - (integer)
    • totalPrice - (integer)

    The response is paginated, you can return only a few of the customer's fields. Take a look at the API V3: sorting and filtering for additional switches you can use.

    You can output additional fields to those listed above as default, see the API v3 Discovery APP for additional details.

    Accepts and returns JSON as Content-Type.


    Request:

    GET /webresources/api/v3/sites/current/customers/10428439/orders HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    {
      "items": [{
            "assignedUserId":null
            "categoryId":10044
            "countryCode":"US"
            "createDate":"2016-10-10T16:56:04.5"
            "cycleTypeId":1
            "destinationAddressIsResidential":null
            "directDebitDays":0
            "directDebitProcessed":false
            "directDebitTypeId":0
            "discountCodeId":73824
            "discountRate":1262.2
            "endRecurDate":null
            "entityId":17759319
            "giftVoucherAmount":null
            "giftVoucherId":null
            "id":1162870
            "integrationId":null
            "invoiceDate":"2016-10-10T00:00:00"
            "invoiceNumber":"92111"
            "invoiced":true
            "isIntermediate":false
            "lastUpdateDate":"2016-10-10T20:12:07.77"
            "name":"Online Shop 10-Oct-2016 04:56 PM"
            "nextInvoiceDate":null
            "parentId":null
            "paymentMethodTypeId":1
            "quote":false
            "recur":false
            "shippingAttention":""
            "shippingDescription":"United States"
            "shippingInstructions":""
            "shippingOptionId":322049
            "shippingPrice":200
            "shippingRateKey":null
            "shippingTaxRate":0
            "siteId":2455866
            "statusTypeId":3630945
            "taxCodeId":61854
            "totalPrice":11559.8
        },
        {
            "assignedUserId":null
            "categoryId":-1
            "countryCode":"US"
            "createDate":"2016-10-10T15:56:18.237"
            "cycleTypeId":1
            "destinationAddressIsResidential":null
            "directDebitDays":0
            "directDebitProcessed":false
            "directDebitTypeId":0
            "discountCodeId":73824
            "discountRate":1377.42
            "endRecurDate":null
            "entityId":17759319
            "giftVoucherAmount":null
            "giftVoucherId":null
            "id":1162847
            "integrationId":null
            "invoiceDate":"2016-10-10T00:00:00"
            "invoiceNumber":"1029"
            "invoiced":true
            "isIntermediate":null
            "lastUpdateDate":"2016-10-10T15:56:42.73"
            "name":"Check Attributes for this order"
            "nextInvoiceDate":null
            "parentId":null
            "paymentMethodTypeId":1
            "quote":false
            "recur":false
            "shippingAttention":""
            "shippingDescription":"International Shipping"
            "shippingInstructions":""
            "shippingOptionId":322050
            "shippingPrice":300
            "shippingRateKey":null
            "shippingTaxRate":0
            "siteId":2455866
            "statusTypeId":3630945
            "taxCodeId":null
            "totalPrice":12696.78
        }],
      "totalItemsCount": 279,
      "skip": 0,
      "limit": 2
    }

    Sample code

    Get the list of orders for the customer with the ID 10428439

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/customers/10428439/orders",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })

    Get the customer's orders with the total price over 40:

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/customers/10428439/orders?where={'totalPrice':{'$gt':'40'}}",
        type: "GET",
        connection: "keep-alive",    
        contentType: "application/json",
        headers: {
            "Authorization": $.cookie('access_token')
        }
    });
    request.done(function (msg) {
        console.log(msg);
    })
    request.fail(function (jqXHR) {
        console.log("Request failed.");
        console.log("Error code: " + jqXHR.status);
        console.log("Error text: " + jqXHR.statusText);
        console.log("Response text: " + jqXHR.responseText);
    })