Fekra

Create a shipping option

image description

Create a shipping option

Create a shipping option

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

Note: Only “user-defined” type shipping (“type”: 1) options can be added using this API endpoint.

Response

The response should be “201 created” if the shipping option was successfully created.

Here are the parameters you can use when creating a shipping option:

  • "description" – the shipping option’s description (string)
  • "price"(integer)
  • "type" – the type of shipping option (integer)
    • 1 – User defined
  • "taxCodeId"(integer)
  • "countryCode"(string)
  • "postcode"(string)

Sample code

var access_token = BCAPI.Helper.Site.getAccessToken();
var request = $.ajax({
	url: "/webresources/api/v3/sites/current/shippingoptions",
    processData: false,
    data: JSON.stringify({    "description": "My custom shipping option",
	  "type": 1,    "price": 10,    "taxCodeId": 0,    "countryCode": "US",    "postcode": "01010",    "limitDeliveryTo": "US;RO"}),
    type: "POST",    
    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);
})

Leave Comment

Related News

This is a demo store for testing purposes — no orders shall be fulfilled. Dismiss

X