Orders and products

    Get an order's products

    Get the products added to an order.

    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/orders/[order_ID]/products
      • 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.

    • itemId - the address ID (integer)
    • orderId - the order's ID (integer)
    • productId - the address ID (integer)
    • siteId - the site's ID (integer)
    • catalogueId - the product's catalog ID(integer)
    • units - the number of units added to the order (integer)
    • unitPrice - price per unit (integer)
    • unitTaxRate - the tax per unit (integer)
    • discountRate - (integer)
    • totalPrice - (integer)
    • description - (string)
    • supplierCommission- (integer)
    • deleted - (boolean)
    • attributeExtras - (integer)
    • variationId - (integer)
    • product - (JSON)
      • id - (integer)
      • siteId - (integer)
      • name - (string)
      • roleId - (integer)
      • weight - (integer)
      • productCode - (string)
      • tags - (string)
      • unitType - (string)
      • smallImage - (string)
      • largeImage - (string)
      • description - (string)
      • inventoryControl - (boolean)
      • canPreorder - (boolean)
      • minUnits - (integer)
      • maxUnits - (integer)
      • inStock - (integer)
      • onOrder - (integer)
      • reOrder - (integer)
      • reOrderNotified - (boolean)
      • variablePerCycle - (boolean)
      • groupingID - (integer)
      • GroupingDefault - (boolean)
      • electronicProduct - (boolean)
      • displayFileName - (string)
      • size - (integer)
      • downloadLimitCount - (integer)
      • downloadLimitIp - (integer)
      • productWeight - (integer)
      • productVolume - (integer)
      • productHeight - (integer)
      • productDepth - (integer)
      • supplierEntityId - (integer)
      • supplierCommission - (integer)
      • isGiftVoucher - (boolean)
      • poplets - ()
      • attributes - ()
      • custom1 - (string)
      • custom2 - (string)
      • custom3 - (string)
      • custom4 - (string)
      • releaseDate - (dateTime) - the date must be in this format - 2014-09-03T07:00:00
      • expiryDate - (dateTime) - the date must be in this format - 2014-09-03T07:00:00
      • captureDetails - (boolean)
      • isOnSale - (boolean)
      • hideIfNoStock - (boolean)
      • enableDropShipping - (boolean)
      • excludeFromSearch - (boolean)
      • enabled - (boolean)
      • deleted - (boolean)
      • title - (string)
      • reIndex - (boolean)
      • hasAttributes - (boolean)
      • cycleTypeCount - (integer)
      • hasVariations - (boolean)
      • slug - (string)
      • metaProductDescription - (string)

    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/orders/108293/products HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    {
      "items": [
        {
          "itemId": 450,
          "orderId": 108293,
          "productId": 951917,
          "siteId": 38581,
          "catalogueId": null,
          "units": 3,
          "unitPrice": 30,
          "unitTaxRate": 0.5,
          "discountRate": 0,
          "totalPrice": 99,
          "description": "1",
          "supplierCommission": 0,
          "deleted": false,
          "attributeExtras": 0,
          "variationId": 9,
          "deletedByTaskOrAdmin": true,
          "product": {
            "id": 951917,
            "siteId": 38581,
            "name": "T-Shirt",
            "roleId": -1,
            "weight": null,
            "productCode": "D12LSM9Q4F",
            "tags": "",
            "unitType": "",
            "smallImage": "",
            "largeImage": "",
            "description": "\r\n",
            "inventoryControl": true,
            "canPreorder": false,
            "minUnits": 1,
            "maxUnits": -1,
            "inStock": 528,
            "onOrder": 0,
            "reOrder": -1,
            "reOrderNotified": false,
            "variablePerCycle": false,
            "groupingID": null,
            "GroupingDefault": false,
            "electronicProduct": false,
            "displayFileName": null,
            "size": 0,
            "downloadLimitCount": -1,
            "downloadLimitIp": -1,
            "productWeight": -1,
            "productVolume": -1,
            "productHeight": -1,
            "productDepth": -1,
            "supplierEntityId": null,
            "supplierCommission": 0,
            "isGiftVoucher": false,
            "poplets": null,
            "attributes": null,
            "custom1": "",
            "custom2": "",
            "custom3": "",
            "custom4": "",
            "releaseDate": "2014-09-03T07:00:00",
            "expiryDate": "9999-01-01T00:00:00",
            "captureDetails": false,
            "isOnSale": false,
            "hideIfNoStock": false,
            "enableDropShipping": false,
            "excludeFromSearch": false,
            "enabled": true,
            "deleted": false,
            "title": "T-Shirt",
            "reIndex": true,
            "hasAttributes": true,
            "cycleTypeCount": -1,
            "hasVariations": true,
    		"slug": "t-shirt",
            "metaProductDescription": ""
          }
        },
        {
          "itemId": 452,
          "orderId": 108293,
          "productId": 951917,
          "siteId": 38581,
          "catalogueId": null,
          "units": 10,
          "unitPrice": 25,
          "unitTaxRate": 0.5,
          "discountRate": 0,
          "totalPrice": 275,
          "description": "111",
          "supplierCommission": 0,
          "deleted": false,
          "attributeExtras": 0,
          "variationId": 9,
          "deletedByTaskOrAdmin": true,
          "product": {
            "id": 951917,
            "siteId": 38581,
            "name": "T-Shirt",
            "roleId": -1,
            "weight": null,
            "productCode": "D12LSM9Q4F",
            "tags": "",
            "unitType": "",
            "smallImage": "",
            "largeImage": "",
            "description": "\r\n",
            "inventoryControl": true,
            "canPreorder": false,
            "minUnits": 1,
            "maxUnits": -1,
            "inStock": 528,
            "onOrder": 0,
            "reOrder": -1,
            "reOrderNotified": false,
            "variablePerCycle": false,
            "groupingID": null,
            "GroupingDefault": false,
            "electronicProduct": false,
            "displayFileName": null,
            "size": 0,
            "downloadLimitCount": -1,
            "downloadLimitIp": -1,
            "productWeight": -1,
            "productVolume": -1,
            "productHeight": -1,
            "productDepth": -1,
            "supplierEntityId": null,
            "supplierCommission": 0,
            "isGiftVoucher": false,
            "poplets": null,
            "attributes": null,
            "custom1": "",
            "custom2": "",
            "custom3": "",
            "custom4": "",
            "releaseDate": "2014-09-03T07:00:00",
            "expiryDate": "9999-01-01T00:00:00",
            "captureDetails": false,
            "isOnSale": false,
            "hideIfNoStock": false,
            "enableDropShipping": false,
            "excludeFromSearch": false,
            "enabled": true,
            "deleted": false,
            "title": "T-Shirt",
            "reIndex": true,
            "hasAttributes": true,
            "cycleTypeCount": -1,
            "hasVariations": true,
            "slug": "t-shirt",
            "metaProductDescription": ""
          }
        }
      ],
      "totalItemsCount": 2,
      "skip": 0,
      "limit": 10
    }

    Sample code

    Get the addresses for a specific order

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/orders/7051740/products",
        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);
    })

    Add products to an order

    Add new products to an order or updates the number of units.

    Request

    • Method: POST
    • Version: v3
    • 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/orders/[ORDER_ID]/products
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • itemId - the item's ID, this is used to identify this particular order item. For example if you need to delete an element from an order you would reffer it using this ID(integer)
    • orderId - the order's ID (integer)
    • productId - the address ID (integer)
    • siteId - the site's ID (integer)
    • catalogueId - the product's catalog ID (integer)
    • units - the number of units added to the order (integer)
    • unitPrice - price per unit (integer)
    • unitTaxRate - the tax per unit (integer)
    • discountRate - (integer)
    • totalPrice - (integer)
    • description - (string)
    • supplierCommission- (integer)
    • deleted - (boolean)
    • attributeExtras - (integer)
    • variationId - (integer)

    Response

    Returns an empty body if successful or a detailed error message.

    Accepts and returns JSON as Content-Type.


    Request:

    POST /webresources/api/v3/sites/current/orders/108293/products HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    
    
    {
      "items": [
        {
          "productId": 951917,
          "variationId": 9,
          "units": 3,
          "description": "Tailored for you!"
        }
      ]
    }

    Response:

    
    HTTP/1.1 204 NO CONTENT
    Location: /webresources/api/v3/sites/current/orders
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample codes

    Add a product to an existing order. If the "units" field is not present only 1 item will be added.

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/orders/108293/products",
    type: "PUT",
    connection: "keep-alive",    
        contentType: "application/json",
    headers: {
        "Authorization": $.cookie('access_token')
    },
    processData: false,
    data: JSON.stringify({
       "items": [
        {
          "productId": 951890
        }
      ]
      })
    });
    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);
    })

    In this example we will add 3 units of the product with the ID 951917 and variation code 9 to the order:

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/orders/108293/products",
    type: "PUT",
    connection: "keep-alive",    
    contentType: "application/json",
    
    headers: {
        "Authorization": $.cookie('access_token')
    },
    processData: false,
    data: JSON.stringify({
       "items": [
        {
          "productId": 951917,
          "variationId": 9,
          "units": 3,
          "description": "Tailored for you!"
        }
      ]
      })
    });
    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);
    })

    Remove products from an order

    Remove a product from an order.

    Request

    • Method: DELETE
    • Version: v3
    • 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/orders/[ORDER_ID]/products?items=[ITEM_ID]
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Response

    Returns an empty body if successful or a detailed error message.


    Request:

    DELETE /webresources/api/v3/sites/current/orders/108293/products?items=[450] HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json
    

    Response:

    
    HTTP/1.1 204 NO CONTENT
    Location: /webresources/api/v3/sites/current/orders/108293/products
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample codes

    Add a product to an existing order. If the "units" field is not present only 1 item will be added.

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/orders/108293/products?items=[{"itemId":12586375,"orderId":108293,"productId":3909340}]",
    type: "DELETE",
    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);
    })