units-of-measure

units-of-measure.find

Returns all the units of measure.

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

request

{
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "code", "name", … ], // fields to return - string
  "order" : [ "name" ], // sort order of returned units of measure, can contain "id", "-id", "code", "-code", "name", "-name",
            // "showName", "-showName", "decimalPlaces" and "-decimalPlaces" - string
  "limit" : 2, // maximum number of units of measure to return - int(1…100)
  "first" : 30 // index of the first unit of measure to return - int(0…)
}

response

{
  "status" : "ok",
  "unitsOfMeasure" : [ {
    "id" : 3, // identifier - int(1…255)
    "code" : "MQ", // code - string(0…32)
    "name" : { // name - string(2) -> string(0…32)
      "en" : "Kg",
      "it" : "Kg",
      …
    },
    "showName" : true, // indicates if the name should be displayed after prices - bool
    "decimalPlaces" : 2 // decimal places of the quantity that a customer can order - int(0…2)
  }, … ]
}

units-of-measure.get

Returns a unit of measure given its identifier.

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

request

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

response

{
  "status" : "ok",
  "unitsOfMeasure" : {
    "id" : 3, // identifier - int(1…255)
    "code" : "MQ", // code - string(0…32)
    "name" : { // name - string(2) -> string(0…32)
      "en" : "Kg",
      "it" : "Kg",
      …
    },
    "showName" : true, // indicates if the name should be displayed after prices - bool
    "decimalPlaces" : 2 // decimal places of the quantity that a customer can order - int(0…2)
  }
}

units-of-measure.count

Total number of units of measure.

JS
CR.api('commerce.units-of-measure.count', null, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.units-of-measure.count

response

{
  "status" : "ok",
  "count" : 18 // number of units of measure - int(0…255)
}

units-of-measure.create

Creates a new unit of measure.

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

request

{
  "unitOfMeasure" : { // unit of measure to create (required)
    "code" : "KG", // code - string(1…32)
    "name" : { // name - string(2) -> string(0…32)
      "en" : "Kg",
      "it" : "Kg",
      …
    },
    "showName" : true, // indicates if the name should be displayed after prices - bool
    "decimalPlaces" : 2 // decimal places of the quantity that a customer can order - int(0…2)
  }

response

{
  "status" : "ok",
  "id" : 15 // identifier of the new unit of measure - int(1…255)
}

Errors

Field Type Description
unitOfMeasure InvalidValue Can not create more than 255 units of measure

units-of-measure.update

Updates a unit of measure. Any fields left out of the request will remain unchanged.

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

request

{
  "id" : 15, // identifier of the unit of measure to update (required) - int(1…255)
  "unitOfMeasure" : { // unit of measure to update (required)
    "code" : "KG", // code - string(1…32)
    "name" : { // name - string(2) -> string(0…32)
      "en" : "Kg",
      "it" : "Kg",
      …
    },
    "showName" : true, // indicates if the name should be displayed after prices - bool
    "decimalPlaces" : 2 // decimal places of the quantity that a customer can order - int(0…2)
  }

response

{
  "status" : "ok"
}

Errors

Field Type Description
id NotFound Unit if measure <id> does not exist

units-of-measure.delete

Deletes one or more units of measure.

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

request

{
  "ids" : [ 15, 6, … ] // identifiers of the units of measure to delete (required) - int(1…255)
}

response

{
  "status" : "ok"
}