Open2b versione 7.2

tax-areas

tax-areas.find

Returns the tax areas that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.tax-areas.find', request, function(response) { … });
HTTP POST
/api/v8/commerce.tax-areas.find
{
  "conditions" : { // returns the tax areas …
    "isActive" : true, // … that are active or not - bool
    "country" : "GB",   // … that have this country - string(2)
    "after" : 5 // … with identifier after this value - int(0…)
  },
  "fields" : [ "id", "code", "name", … ], // fields to return - string
  "order" : [ "name" ], // sort order of returned tax areas, can contain "id", "-id", "name", "-name", "isActive", "-isActive",
                        // "taxCompanies", "-taxCompanies", "countries" and "-countries" - string
  "limit" : 10, // maximum number of tax areas to return - int(1…)
  "first" : 0 // index of the first tax area to return - int(0…)
}

Response


{
  "status" : "ok",
  "taxAreas" : [ {
    "id" : 5, // identifier - int(1…)
    "code" : "EUROPE", // code - string(0…32)
    "name" : "Europe", // name - string(0…60)
    "isActive" : true, // indicates if it is active - bool
    "taxCompanies" : true, // indicates if taxes are also applied to companies - bool
    "countries" : [ "FR", "GB", … ], // countries which it is applied - string(2)
    "rates" : { // tax rate for each tax class - int(1…) -> decimal[4,2](0…100)
      "1" : 19.50,
      "3" : 0.00,
      "4" : 12.00
    }
  }, … ]
}

tax-areas.get

Returns a tax area given its identifier.

Request

Admin SDK
Admin.api('commerce.tax-areas.get', request, function(response) { … });
HTTP POST
/api/v8/commerce.tax-areas.get
{
  "id" : 5, // identifier (required) - int(1…)
  "fields" : [ "id", "code", "name", … ]  // fields to return - string
}

Response

{
  "status" : "ok",
  "taxArea" : { // (can be null)
    "id" : 5, // identifier - int(1…)
    "code" : "EUROPE", // code - string(0…32)
    "name" : "Europe", // name - string(0…60)
    "isActive" : true, // indicates if it is active - bool
    "taxCompanies" : true, // indicates if taxes are also applied to companies - bool
    "countries" : [ "FR", "GB", … ], // countries which it is applied - string(2)
    "rates" : { // tax rate for each tax class - int(1…) -> decimal[4,2](0…100)
      "1" : 19.50,
      "3" : 0.00,
      "4" : 12.00
    }
  }
}

tax-areas.count

Number of tax areas that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.tax-areas.count', request, function(response) { … });
HTTP POST
/api/v8/commerce.tax-areas.count
{
  "conditions" : { // counts the tax areas …
    "isActive" : true, // … that are active or not - bool
    "country" : "GB", // … that have this country - string(2)
    "after" : 5 // … with identifier after this value - int(0…)
  }
}

Response

{
  "status" : "ok",
  "count" : 6 // number of tax areas - int(0…)
}

tax-areas.create

Creates a new tax area.

Request

Admin SDK
Admin.api('commerce.tax-areas.create', request, function(response) { … });
HTTP POST
/api/v8/commerce.tax-areas.create
{
  "taxArea" : { // tax area to create (required)
    "code" : "EUROPE", // code - string(0…32)
    "name" : "Europe", // name - string(0…60)
    "isActive" : true, // indicates if it is active - bool
    "taxCompanies" : true, // indicates if taxes are also applied to companies - bool
    "countries" : [ "FR", "GB", … ], // countries which it is applied - string(2)
    "rates" : { // tax rate for each tax class - int(1…) -> decimal[4,2](0…100)
      "1" : 19.50,
      "3" : 0.00,
      "4" : 12.00
    }
  }
}

Response

{
  "status" : "ok",
  "id" : 5 // identifier of the new tax area - int(1…)
}

Errors

Field Type Description
countries InvalidValue Country code '<country>' does not exist
countries Malformed Country '<country>' is not a valid country code
countries Repeated Repeated country code '<country>'
isActive Invalid Default tax area must be active
rates NotFound Tax class <taxClass> does not exist

tax-areas.update

Updates a tax area. Any fields left out of the request will remain unchanged.

Request

Admin SDK
Admin.api('commerce.tax-areas.update', request, function(response) { … });
HTTP POST
/api/v8/commerce.tax-areas.update
{
  "id" : 5, // identifier of the tax area to update (required) - int(1…)
  "taxArea" : { // tax area's fields to update (required)
    "code" : "EUROPE", // code - string(0…32)
    "name" : "Europe", // name - string(0…60)
    "isActive" : true, // indicates if it is active - bool
    "taxCompanies" : true, // indicates if taxes are also applied to companies - bool
    "countries" : [ "FR", "GB", … ], // countries which it is applied - string(2)
    "rates" : { // tax rate for each tax class - int(1…) -> decimal[4,2](0…100)
      "1" : 19.50,
      "3" : 0.00,
      "4" : 12.00
    }
  }
}

Response

{
  "status" : "ok"
}

Errors

Field Type Description
countries InvalidValue Country code '<country>' does not exist
countries Malformed Country '<country>' is not a valid country code
countries Repeated Repeated country code '<country>'
id NotFound Tax area <id> does not exist
isActive InvalidValue Default tax area must be active
rates NotFound Tax class <taxClass> does not exist

tax-areas.delete

Deletes one or more tax areas.

Request

Admin SDK
Admin.api('commerce.tax-areas.delete', request, function(response) { … });
HTTP POST
/api/v8/commerce.tax-areas.delete
{
  "ids" : [ 5, 1, 6, … ] // identifiers of the tax areas to delete (required) - int(1…)
}

Response

{
  "status" : "ok"
}

Errors

Field Type Description
ids InvalidValue Tax area <id> is used by customer group <group>