shipping-methods

shipping-methods.compute-costs

Calculates shipping costs for one or more goods.

JS
CR.api('commerce.shipping-methods.compute-costs', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.shipping-methods.compute-costs

request

{
  "goods" : [ { // goods for witch calculate the costs (required)
    "weight" : 12.780, // weight (required) - decimal[8,3](0…)
    "quantity" : 5.00, // number of products (required) - decimal[10,2](0…)
    "subtotal" : 127.970, // subtotal (required) - decimal[10,3]
    "taxedSubtotal" : 152.280 // subtotal taxes included (required) - decimal[10,3]
  }, … ],
  "conditions" : { // returns the costs only for the shipping methods …
    "ids" : [ 3, 1, … ], // … with these identifiers - bigint(1…)
    "isActive" : true, // … that are visible or not on shop - bool
    "country" : "GB", // … that are applicable to this country (ISO code) - string(2)
    "stateProv" : "LND" // … that are applicable to this state/province/county (ISO code) - string(1…3)
  }
}

response

{
  "status" : "ok",
  "costs" : { // costs for each shipping method - int(1…) -> decimal[10,3](0…)
    "1" : 5.295,
    "3" : 8.060
  }
}

shipping-methods.find

Returns the shipping methods that meet the given conditions.

JS
CR.api('commerce.shipping-methods.find', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.shipping-methods.find

request

{
  "conditions" : { // returns only the shipping methods …
    "ids" : [ 3, 1, … ], // … with these identifiers - int(1…)
    "isActive" : true, // … that are visible or not visible on the shop - bool
    "isDefault" : false,  // … that are the default shipping method or not - bool
    "country" : "GB", // … that are applicable to this country (ISO code) - string(2)
    "stateProv" : "LND", // … that are applicable to this state/province/county (ISO code) - string(1…3)
    "weight" : 23.893, // … that are applicable to this weight - decimal[8,3](0…)
    "quantity" : 5.00, // … that are applicable to this number of products - decimal[10,2](0…)
    "subtotal" : 175.780 // … that are applicable to this subtotal - decimal[10,3](0…)
  },
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "name", … ], // fields to return - string
  "order" : [ "name" ], // sort order of returned shipping methods, can contain "id", "-id", "name", "-name", "isDomestic", "-isDomestic",
                        // "isInsured", "-isInsured", "isActive", "-isActive", "paymentOnDelivery" and "-paymentOnDelivery" - string
  "limit" : 10, // maximum number of shipping methods to return - int(1…100)
  "first" : 0 // index of the first shipping method to return - int(0…)
}

response

{
  "status" : "ok",
  "shippingMethods" : [ {
    "id" : 3, // identifier - int(1…)
    "name" : { // name - string(2) -> string(0…80)
      "en" : "Next day",
      "it" : "Giorno successivo"
    },
    "basedOn" : "Weight", // indicates on what the cost is based, can be "Weight", "Quantity" or "Subtotal" - string
    "isDomestic" : false, // indicates if it is domestic - bool
    "isInsured" : true, // indicates if it is insured - bool
    "isActive" : true, // indicates if it is visible on shop - bool
    "isDefault" : false, // indicates if it is the default shipping method - bool
    "paymentOnDelivery" : 9, // payment method (id) on delivery that can be used with this shipping method (can be null) - int(1…)
    "shippingRates" : [ { // shipping cost rates
      "start" : 0.000, // from this value ( of weight, quantity or subtotal ) - decimal[10,3](0…)
      "limit" : 5.000, // to this value ( of weight, quantity or subtotal ) (required) - decimal[10,3](0…)
      "fixedCost" : 5.600, // … apply this fixed cost - decimal[10,3](0…)
      "unitCost" : 0.550 // … apply this unit cost - decimal[10,3](0…)
    }, … ],
    "insuranceRates" : [ { // insurance cost rates
      "start" : 0.000, // from this value ( of weight, quantity or subtotal ) - decimal[10,3](0…)
      "limit" : 25.000, // to this value ( of weight, quantity or subtotal ) (required) - decimal[10,3](0…)
      "fixedCost" : 2.000, // … apply this fixed cost - decimal[10,3](0…)
      "percentCost" : 0.25 // … apply this percent cost - decimal[4,2](0…)
    }, … ],
    "taxClass" : 7, // tax class (id) to use for tax calculation (can be null) - int(1…)
    "zones" : [ "GB", … ] // countries, provinces, states or counties witch it is applied - string(1…3)
  }, … ]
}

shipping-methods.get

Returns a shipping method given its identifier.

JS
CR.api('commerce.shipping-methods.get', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.shipping-methods.get

request

{
  "id" : 3, // identifier - int(1…)
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "name", … ]  // fields to return - string
}

response

{
  "status" : "ok",
  "shippingMethod" : { // (can be null)
    "id" : 3, // identifier - int(1…)
    "name" : { // name - string(2) -> string(0…80)
      "en" : "Next day",
      "it" : "Giorno successivo"
    },
    "basedOn" : "Weight", // indicates on what the cost is based, can be "Weight", "Quantity" or "Subtotal" - string
    "isDomestic" : false, // indicates if it is domestic - bool
    "isInsured" : true, // indicates if it is insured - bool
    "isActive" : true, // indicates if it is visible on shop - bool
    "isDefault" : false, // indicates if it is the default shipping method - bool
    "paymentOnDelivery" : 9, // payment method (id) on delivery that can be used with this shipping method (can be null) - int(1…)
    "shippingRates" : [ { // shipping cost rates
      "start" : 0.000, // from this value ( of weight, quantity or subtotal ) - decimal[10,3](0…)
      "limit" : 5.000, // to this value ( of weight, quantity or subtotal ) (required) - decimal[10,3](0…)
      "fixedCost" : 5.600, // … apply this fixed cost - decimal[10,3](0…)
      "unitCost" : 0.550 // … apply this unit cost - decimal[10,3](0…)
    }, … ],
    "insuranceRates" : [ { // insurance cost rates
      "start" : 0.000, // from this value ( of weight, quantity or subtotal ) - decimal[10,3](0…)
      "limit" : 25.000, // to this value ( of weight, quantity or subtotal ) (required) - decimal[10,3](0…)
      "fixedCost" : 2.000, // … apply this fixed cost - decimal[10,3](0…)
      "percentCost" : 0.25 // … apply this percent cost - decimal[4,2](0…)
    }, … ],
    "taxClass" : 7, // tax class (id) to use for tax calculation (can be null) - int(1…)
    "zones" : [ "GB", … ] // countries, provinces, states or counties witch it is applied - string(1…3)
  }
}

shipping-methods.count

Number of shipping methods that meet the given conditions.

JS
CR.api('commerce.shipping-methods.count', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.shipping-methods.count

request

{
  "conditions" : { // counts only the shipping methods …
    "ids" : [ 3, 1, … ], // … with these identifiers - int(1…)
    "isActive" : true, // … that are visible or not visible on the shop - bool
    "isDefault" : false,  // … that are the default shipping method or not - bool
    "country" : "GB", // … that are applicable to this country (ISO code) - string(2)
    "stateProv" : "LND", // … that are applicable to this state/province/county (ISO code) - string(1…3)
    "weight" : 23.893, // … that are applicable to this weight - decimal[8,3](0…)
    "quantity" : 5.00, // … that are applicable to this number of products - decimal[10,2](0…)
    "subtotal" : 175.780 // … that are applicable to this subtotal - decimal[10,3](0…)
  }
}

response

{
  "status" : "ok",
  "count" : 4 // number of shipping methods - int(0…)
}

shipping-methods.create

Creates a new shipping method.

JS
CR.api('commerce.shipping-methods.create', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.shipping-methods.create

request

{
  "shippingMethod" : { // shipping method to create (required)
    "name" : { // name - string(2) -> string(0…80)
      "en" : "Next day",
      "it" : "Giorno successivo"
    },
    "basedOn" : "Weight", // indicates on what cost is based, can be "Weight", "Quantity" or "Subtotal" - string
    "isDomestic" : false, // indicates if it is domestic - bool
    "isActive" : true, // indicates if it is visible on shop - bool
    "isDefault" : false, // indicates if it is the default shipping method - bool
    "paymentOnDelivery" : 9, // payment method (id) on delivery that can be used with this shipping method (can be null) - int(1…)
    "shippingRates" : [ { // shipping cost rates
      "start" : 0.000, // from this value ( of weight, quantity or subtotal ) - decimal[10,3](0…)
      "limit" : 5.000, // to this value ( of weight, quantity or subtotal ) (required) - decimal[10,3](0…)
      "fixedCost" : 5.600, // … apply this fixed cost - decimal[10,3](0…)
      "unitCost" : 0.550 // … apply this unit cost - decimal[10,3](0…)
    }, … ],
    "insuranceRates" : [ { // insurance cost rates
      "start" : 0.000, // from this value ( of weight, quantity or subtotal ) - decimal[10,3](0…)
      "limit" : 25.000, // to this value ( of weight, quantity or subtotal ) (required) - decimal[10,3](0…)
      "fixedCost" : 2.000, // … apply this fixed cost - decimal[10,3](0…)
      "percentCost" : 0.25 // … apply this percent cost - decimal[4,2](0…)
    }, … ],
    "taxClass" : 7, // tax class (id) to use for tax calculation (can be null) - int(1…)
    "zones" : [ "GB", … ] // countries, provinces, states or counties witch it is applied - string(1…3)
  }
}

response

{
  "status" : "ok",
  "id" : 3 // identifier of the new shipping method - int(1…)
}

Errors

Field Type Description
paymentOnDelivery NotFound Payment method <paymentOnDelivery> does not exist
taxClass NotFound Tax class <taxClass> does not exist

shipping-methods.update

Updates a shipping method. Any fields left out of the request will remain unchanged.

JS
CR.api('commerce.shipping-methods.update', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.shipping-methods.update

request

{
  "id" : 3, // identifier of the shipping method to update (required)
  "shippingMethod" : { // shipping method's fields to update (required)
    "name" : { // name - string(2) -> string(0…80)
      "en" : "Next day",
      "it" : "Giorno successivo"
    },
    "isActive" : true, // indicates if it is visible on shop - bool
    "isDefault" : false, // indicates if it is the default shipping method - bool
    "paymentOnDelivery" : 9, // payment method (id) on delivery that can be used with this shipping method (can be null) - int(1…)
    "shippingRates" : [ { // shipping cost rates
      "start" : 0.000, // from this value ( of weight, quantity or subtotal ) - decimal[10,3](0…)
      "limit" : 5.000, // to this value ( of weight, quantity or subtotal ) (required) - decimal[10,3](0…)
      "fixedCost" : 5.600, // … apply this fixed cost - decimal[10,3](0…)
      "unitCost" : 0.550 // … apply this unit cost - decimal[10,3](0…)
    }, … ],
    "insuranceRates" : [ { // insurance cost rates
      "start" : 0.000, // from this value ( of weight, quantity or subtotal ) - decimal[10,3](0…)
      "limit" : 25.000, // to this value ( of weight, quantity or subtotal ) (required) - decimal[10,3](0…)
      "fixedCost" : 2.000, // … apply this fixed cost - decimal[10,3](0…)
      "percentCost" : 0.25 // … apply this percent cost - decimal[4,2](0…)
    }, … ],
    "taxClass" : 7, // tax class (id) to use for tax calculation (can be null) - int(1…)
    "zones" : [ "GB", … ] // countries, provinces, states or counties witch it is applied - string(1…3)
  }
}

response

{
  "status" : "ok"
}

Errors

Field Type Description
id NotFound Shipping method <id> does not exist
paymentOnDelivery NotFound Payment method <paymentOnDelivery> does not exist
taxClass NotFound Tax class <taxClass> does not exist

shipping-methods.delete

Deletes one o more shipping methods.

JS
CR.api('commerce.shipping-methods.delete', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.shipping-methods.delete

request

{
  "ids" : [ 3, 1, … ] // identifiers of the shipping methods to delete (required) - int(1…)
}

response

{
  "status" : "ok"
}