options

options.find

Returns the options that meet the given conditions.

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

request

{
  "conditions" : { // returns the options …
    "ids" : [ 46, 19, … ], // … with these identifiers - int(1…)
    "variants" : [ 81, 22, … ] // … that belong to these variants (id) - int(1…)
  },
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "code", … ], // fields to return - string
  "order" : [ "name" ], // sort order of returned options, can contain "id", "-id", "variant", "-variant", "code", "-code",
                        // "name", "-name", "position" and "-position" - string
  "limit" : 10, // maximum number of options to return - int(1…100)
  "first" : 0 // index of the first option to return - int(0…)
}

response

{
  "status" : "ok",
  "options" : [ {
    "id" : 46, // identifier - int(1…)
    "variant" : 81, // variant (id) - int(1…)
    "code" : "RED", // code - string(1…32)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Red",
      "it" : "Rosso"
    },
    "position" : 3, // position - int(1…)
    "icon" : { // icon (can be null)
      "color" : null, // color, hexadecimal format (can be null) - string(6)
      "image" : { // image (can be null)
        "url" : "http://…", // image URL - string(10…)
        "width"  : 16, // width in pixel - int(1…35)
        "height" : 16 // height in pixel - int(1…35)
      }
    }
  }, … ]
}

options.get

Returns an option given its identifier.

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

request

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

response

{
  "status" : "ok",
  "option" : { // (can be null)
    "id" : 46, // identifier - int(1…)
    "variant" : 81, // variant (id) - int(1…)
    "code" : "RED", // code - string(1…32)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Red",
      "it" : "Rosso"
    },
    "position" : 3, // position - int(1…)
    "icon" : { // icon (can be null)
      "color" : null, // color, hexadecimal format (can be null) - string(6)
      "image" : { // image (can be null)
        "url" : "http://…", // image URL - string(10…)
        "width"  : 16, // width in pixel - int(1…35)
        "height" : 16 // height in pixel - int(1…35)
      }
    }
  }
}

options.count

Number of options that meet the given conditions.

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

request

{
  "conditions" : { // returns the options …
    "ids" : [ 46, 19, … ], // … with these identifiers - int(1…)
    "variants" : [ 81, 22, … ] // … that belong to these variants (id) - int(1…)
  }
}

response

{
  "status" : "ok",
  "count" : 12 // number of options - int(0…)
}

options.create

Creates a new option.

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

request

{
  "option" : { // option to create (required)
    "variant" : 81, // variant (id) (required) - int(1…)
    "code" : "RED", // code (required) - string(1…32)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Red",
      "it" : "Rosso"
    },
    "position" : 3, // position - int(1…)
    "icon" : { // icon (can be null)
      "color" : null, // color, hexadecimal format (can be null) - string(6)
      "image" : { // image (can be null)
        "name" : "icon.png", // file name - string(1…255)
        "content" : "N3R…zaA==" // content encoded in base64 - string(100…50000)
      }
    }
  }
}

response

{
  "status" : "ok",
  "id" : 43 // identifier of the new option - int(1…)
}

Errors

Field Type Description
code AlreadyExists Option code '<code>' already exists for variant <variant>
variant NotFound Variant <variant> does not exist

options.update

Updates an option. Any fields left out of the request will remain unchanged.

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

request

{
  "id" : 43, // identifier of the option to update (required)
  "option" : { // option's fields to update (required)
    "code" : "RED", // code - string(1…32)
    "name" : { // name - string(2) -> string(0…60)
      "en" : "Red",
      "it" : "Rosso"
    }
    "position" : 3, // position - int(1…)
    "icon" : { // icon (can be null)
      "color" : null, // color, hexadecimal format (can be null) - string(6)
      "image" : { // image (can be null)
        "name" : "icon.png", // file name - string(1…255)
        "content" : "N3R…zaA==" // content encoded in base64 - string(100…50000)
      }
    }
  }
}

response

{
    "status" : "ok"
}

Errors

Field Type Description
code AlreadyExists Option code '<code>' already exists for variant <variant>
id NotFound Option <id> does not exist

options.delete

Deletes one or more options.

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

request

{
  "ids" : [ 43, 25, 108, … ] // identifiers of the options to delete (required) - int(1…)
}

response

{
  "status" : "ok"
}