Prices

    Get prices

    Gets the list of price resources available.

    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/prices
      • 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.

    • productId - the id of the price (numeric)
    • siteId - the id of the site (numeric)
    • countryCode (string)
    • taxCodeId - the ID of the tax code applied (numeric)
    • wTaxCodeId - the ID of the tax code applied for wholesalers (numeric)
    • retailPrice - the retail price (numeric)
    • salePrice - the sale price (numeric)
    • salePrice2 (numeric)
    • salePrice3 (numeric)
    • quantity2 - the 2-nd quantity threshold (if the volume discounts is enabled) (numeric)
    • quantity3 - the 3-rd quantity threshold (if the volume discounts is enabled)(numeric)
    • wSalePrice2 - the wholesaler sale price for the 2-nd threshold(numeric)
    • wSalePrice3 - the wholesaler sale price for the 3-rd threshold(numeric)
    • wQuantity2 - the 2-nd quantity threshold for wholesalers (if the volume discounts is enabled) (numeric)(numeric)
    • wQuantity3 - the 3-nd quantity threshold for wholesalers (if the volume discounts is enabled) (numeric)(numeric)

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

    Response:

    {
      "items": [
        {
          "productId": 3909340,
          "siteId": 246884,
          "countryCode": "AD",
          "taxCodeId": -1,
          "wTaxCodeId": -1,
          "retailPrice": 25,
          "salePrice": 25,
          "salePrice2": null,
          "salePrice3": null,
          "quantity2": null,
          "quantity3": null,
          "wSalePrice": 0,
          "wSalePrice2": null,
          "wSalePrice3": null,
          "wQuantity2": null,
          "wQuantity3": null
        },
        {
          "productId": 3909340,
          "siteId": 246884,
          "countryCode": "AE",
          "taxCodeId": -1,
          "wTaxCodeId": -1,
          "retailPrice": 25,
          "salePrice": 25,
          "salePrice2": null,
          "salePrice3": null,
          "quantity2": null,
          "quantity3": null,
          "wSalePrice": 0,
          "wSalePrice2": null,
          "wSalePrice3": null,
          "wQuantity2": null,
          "wQuantity3": null
        }
      ],
      "totalItemsCount": 2,
      "skip": 0,
      "limit": 10
    }

    Sample code

    Get the list of prices for all the products on your site

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/prices",
        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 prices for a particular product

    Note: when getting the price for a particular product you have to provide the countryCode parameter in the request

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/prices/3909340?where={"countryCode":"US"}",
        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);
    })

    Create a new price for a product

    Create a new price for a particular product.

    Note: when editing a particular price the countryCode field is mandatory

    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/prices/
      • Alternatively, use siteID instead of 'current'
    • Authorization header: This should contain the authorization token. Here is how to obtain the token.

    Parameters

    • productId - (integer)
    • siteId - (integer)
    • countryCode - this field is mandatory (integer)
    • taxCodeId - (integer)
    • wTaxCodeId - (integer)
    • retailPrice - (double)
    • salePrice - (double)
    • salePrice2 - (double)
    • salePrice3 - (double)
    • quantity2 - (integer)
    • quantity3 - (double)
    • wSalePrice - (double)
    • wSalePrice2 - (double)
    • wSalePrice3 - (double)
    • wQuantity2 - (integer)
    • wQuantity3 - (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/prices HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json

    Response:

    {% raw %}HTTP/1.1 201 CREATED
    Location: /webresources/api/v3/sites/current/prices
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample code

    Create a new price

    
    var request = $.ajax({
      url: "/webresources/api/v3/sites/current/prices",
      type: "POST",
      connection: "keep-alive",    
      contentType: "application/json",
      processData: false,
      headers: {
          "Authorization": $.cookie('access_token'),
        
      },
      data: JSON.stringify({
           "productId": 951953,
           "siteId": 38592,
           "countryCode": "US",
           "taxCodeId": -1,
           "wTaxCodeId": -1,
           "retailPrice": 27,
           "salePrice": 27,
           "salePrice2": null,
           "salePrice3": null,
           "quantity2": null,
           "quantity3": null,
           "wSalePrice": 0,
           "wSalePrice2": null,
           "wSalePrice3": null,
           "wQuantity2": null,
           "wQuantity3": null
        })
    });
    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);
    })

    Edit a price

    Edit the details for a particular price

    Note: when editing a particular price the countryCode field is mandatory

    Request

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

    Parameters

    • productId - (integer)
    • siteId - (integer)
    • countryCode - this field is mandatory (integer)
    • taxCodeId - (integer)
    • wTaxCodeId - (integer)
    • retailPrice - (double)
    • salePrice - (double)
    • salePrice2 - (double)
    • salePrice3 - (double)
    • quantity2 - (integer)
    • quantity3 - (double)
    • wSalePrice - (double)
    • wSalePrice2 - (double)
    • wSalePrice3 - (double)
    • wQuantity2 - (integer)
    • wQuantity3 - (integer)

    Response

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

    Accepts and returns JSON as Content-Type.


    Request:

    PUT /webresources/api/v3/sites/current/prices HTTPS/1.1
    Authorization: 14f87f21c5ea4830a06a6314a8aad82b45bc61dc08f24a0fb55599cea83ca811
    Connection: keep-alive
    Content-Type: application/json

    Response:

    {% raw %}
    HTTP/1.1 204 NO CONTENT
    Location: /webresources/api/v3/sites/current/prices/[product_ID]
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample code

    Edit a price value name

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
    url: "/webresources/api/v3/sites/current/prices/951953",
    type: "PUT",
    connection: "keep-alive",    
        contentType: "application/json",
    headers: {
        "Authorization": $.cookie('access_token')
    },
    processData: false,
    data: JSON.stringify({
         "productId": 951953,
         "siteId": 38592,
    	 "countryCode": "US",
    	 "retailPrice": 50
          })
    });
    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);
    })

    Delete a price for a product

    Delete a product for a particular product.

    Note: when deleting a particular price the countryCode field is mandatory

    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/prices/[product_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/prices/951953?where={"countryCode":"US"} 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/prices/[product_ID]
    Content-Type: application/json; charset=utf-8
    Content-Length: length

    Sample code

    Delete a price for a particular product

    var access_token = BCAPI.Helper.Site.getAccessToken();
    var request = $.ajax({
        url: "/webresources/api/v3/sites/current/prices/951953?where={"countryCode":"US"}",
        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);
    })