units-of-measure

units-of-measure.find

Returns all the units of measure.

Request

Admin SDK
Admin.api('commerce.units-of-measure.find', request, function(response) { … });
HTTP POST
/api/v6/commerce.units-of-measure.find
{
  "conditions" : { // returns the units of measure …
    "after" : 2 // … with identifier after this value - int(0…)
  },
  "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…)
  "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.

Request

Admin SDK
Admin.api('commerce.units-of-measure.get', request, function(response) { … });
HTTP POST
/api/v6/commerce.units-of-measure.get
{
  "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

Number of units of measure that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.units-of-measure.count', request, function(response) { … });
HTTP POST
/api/v6/commerce.units-of-measure.count
{
  "conditions" : { // counts the units of measure …
    "after" : 2 // … with identifier after this value - int(0…)
  }
}

Response

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

units-of-measure.create

Creates a new unit of measure.

Request

Admin SDK
Admin.api('commerce.units-of-measure.create', request, function(response) { … });
HTTP POST
/api/v6/commerce.units-of-measure.create
{
  "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.

Request

Admin SDK
Admin.api('commerce.units-of-measure.update', request, function(response) { … });
HTTP POST
/api/v6/commerce.units-of-measure.update
{
  "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.

Request

Admin SDK
Admin.api('commerce.units-of-measure.delete', request, function(response) { … });
HTTP POST
/api/v6/commerce.units-of-measure.delete
{
  "ids" : [ 15, 6, … ] // identifiers of the units of measure to delete (required) - int(1…255)
}

Response

{
  "status" : "ok"
}
`