Open2b versione 7.2

return-rules

return-rules.check

Checks and returns the return terms for one or more order items, according to the rules.

Request

Admin SDK
Admin.api('commerce.return-rules.check', request, function(response) { … });
HTTP POST
/api/v8/commerce.return-rules.check
{
  "orderItems" : [ 8029651, 8029653, … ] // order items (id) to check (required) - int(1…)
}

Response

{
  "status" : "ok",
  "terms" : [ { // return terms
    "orderItem" : 8029651, // order item (id) - int(1…)
    "shipment" : 739820, // shipment (id) - int(1…)
    "isReturnable" : true, // indicates if the order item is returnable - bool
    "rule" : 7, // return rule (id) that applies (can be null) - int(1…)
    "quantity" : 3.00, // quantity that can be returned - decimal[8,2](0…)
    "lastDateToReturn" : "2020-10-21" // last valid date to return the item (can be null) - date
  }, … ]
}

Errors

Field Type Description
ids Malformed An order item id is repeated

Notes

return-rules.find

Returns the return rules that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.return-rules.find', request, function(response) { … });
HTTP POST
/api/v8/commerce.return-rules.find
{
  "conditions" : { // return only the rules …
    "after" : 7 // … with identifier after this value - int(0…)
  },
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "position", "name", … ], // returns only these fields - string
  "order" : [ "name" ], // sort order of returned return rules, can contain "position", "-position", "name", "-name",
                        // "fromOrderDate", "-fromOrderDate", "toOrderDate", "-toOrderDate", "allowsReturn", "-allowsReturn", "approveAutomatically", "-approveAutomatically", "maxDaysToReturn", "-maxDaysToReturn"
  "limit" : 10, // maximum number of return rules to return - int(1…)
  "first" : 0 // index of the first return rule to return - int(0…)
}

Response

{
  "status" : "ok",
  "rules" : [ {
    "id" : 7, // identifier - int(1…)
    "position" : 3, // position - int(1…)
    "name" : "...", // name - string(0…60)
    "allowReturns" : true, // indicates if returns are allowed - bool
    "approveAutomatically" : false, // indicates if allowed returns are automatically approved - bool
    "reasons" : [ 3, 6, 10, … ], // reasons (id) that the customer can choose (can be null) - int(1…)
    "maxDaysToReturn" : 30, // maximum number of days, from delivery date, to request a return - int(1…5000)
    "description" : { // description - string(2) -> string(0…1000)
      "en" : "...",
      "it" : "..."
    },
    "fromOrderDate" : "2020-01-01", // applied to orders from this order date (can be null) - date
    "toOrderDate" : "2020-12-31", // applied to orders up to this order date (can be null) - date
    "resources" : { // resources to which it is applied (can be null)
      "type" : "Product", // type of resources, can be "Product", "Department", "Producer" or "AttributeValue" - string
      "ids" : [ 287, 98, … ] // products, departments, producers or attribute values (id) - int(1…)
    },
    "customerType" : "Person", // customer to which it is applied (can be null), can be "Person" or "Company"
    "groups" : [ 5, 7, … ], // customer groups (id) to which it is applied (can be null) - int(1…255)
    "countries" : { // countries of the order to which it is applied (can be null)
      "codes" : [ "UK", "IT", … ], // codes (ISO code) - string(2)
      "refersTo" : "Shipping" // indicates if the codes refers to billing or shipping address of the order, can be "Billing" or "Shipping" - string
    }
  }, … ]
}

return-rules.get

Returns a return rule given its identifier.

Request

Admin SDK
Admin.api('commerce.return-rules.get', request, function(response) { … });
HTTP POST
/api/v8/commerce.return-rules.get
{
  "id" : 7, // identifier (required) - int(1…)
  "language" : "en", // language ( ISO code ) of the texts to return - string(2)
  "fields" : [ "id", "position", "name", … ] // returns only these fields - string
}

Response

{
  "status" : "ok",
  "rule"  : { // (can be null)
    "id" : 7, // identifier - int(1…)
    "position" : 3, // position - int(1…)
    "name" : "...", // name - string(0…60)
    "allowReturns" : true, // indicates if returns are allowed - bool
    "approveAutomatically" : false, // indicates if allowed returns are automatically approved - bool
    "reasons" : [ 3, 6, 10, … ], // reasons (id) that the customer can choose (can be null) - int(1…)
    "maxDaysToReturn" : 30, // maximum number of days, from delivery date, to request a return - int(1…5000)
    "description" : { // description - string(2) -> string(0…1000)
      "en" : "...",
      "it" : "..."
    },
    "fromOrderDate" : "2020-01-01", // applied to orders from this order date (can be null) - date
    "toOrderDate" : "2020-12-31", // applied to orders up to this order date (can be null) - date
    "resources" : { // resources to which it is applied (can be null)
      "type" : "Product", // type of resources, can be "Product", "Department", "Producer" or "AttributeValue" - string
      "ids" : [ 287, 98, … ] // products, departments, producers or attribute values (id) - int(1…)
    },
    "customerType" : "Person", // customer to which it is applied (can be null), can be "Person" or "Company"
    "groups" : [ 5, 7, … ], // customer groups (id) to which it is applied (can be null) - int(1…255)
    "countries" : { // countries of the order to which it is applied (can be null)
      "codes" : [ "UK", "IT", … ], // codes (ISO code) - string(2)
      "refersTo" : "Shipping" // indicates if the codes refers to billing or shipping address of the order, can be "Billing" or "Shipping" - string
    }
  }
}

return-rules.count

Number of return rules that meet the given conditions.

Request

Admin SDK
Admin.api('commerce.return-rules.count', request, function(response) { … });
HTTP POST
/api/v8/commerce.return-rules.count
{
  "conditions" : { // counts the rules …
    "after" : 7 // … with identifier after this value - int(0…)
  }
}

Response

{
  "status" : "ok",
  "count" : 16 // number of return rules - int(0…)
}

return-rules.create

Creates a new return rule.

Request

Admin SDK
Admin.api('commerce.return-rules.create', request, function(response) { … });
HTTP POST
/api/5/commerce.return-rules.create
{
  "rule" : { // rule to create (required)
    "position" : 3, // position - int(1…)
    "name" : "...", // name - string(0…60)
    "allowReturns" : true, // indicates if returns are allowed - bool
    "approveAutomatically" : false, // indicates if allowed returns are automatically approved - bool
    "reasons" : [ 3, 6, 10, … ], // reasons (id) that the customer can choose (can be null) - int(1…)
    "maxDaysToReturn" : 30, // maximum number of days, from delivery date, to request a return - int(1…5000)
    "description" : { // description - string(2) -> string(0…1000)
      "en" : "...",
      "it" : "..."
    },
    "fromOrderDate" : "2020-01-01", // applied to orders from this order date (can be null) - date
    "toOrderDate" : "2020-12-31", // applied to orders up to this order date (can be null) - date
    "resources" : { // resources to which it is applied (can be null)
      "type" : "Product", // type of resources, can be "Product", "Department", "Producer" or "AttributeValue" - string
      "ids" : [ 287, 98, … ] // products, departments, producers or attribute values (id) - int(1…)
    },
    "customerType" : "Person", // customer to which it is applied (can be null), can be "Person" or "Company"
    "groups" : [ 5, 7, … ], // customer groups (id) to which it is applied (can be null) - int(1…255)
    "countries" : { // countries to which it is applied (can be null)
      "codes" : [ "UK", "IT", … ], // codes (ISO) of the countries - string(2)
      "refersTo" : "Shipping" // indicates if the codes refers to billing or shipping address of the order, can be "Billing" or "Shipping" - string
    }
  }
}

Response

{
  "status" : "ok",
  "id" : 7 // identifier of the new return rule - int(1…)
}

Errors

Field Type Description
countries Malformed '<code>' is not a valid country code
countries Malformed A country code is repeated
countries NotFound Country '<code>' does not exist
create NotAvailable Return rules are not available for this installation
groups Malformed There must be no more than 20 customer groups
groups NotFound Customer group <group> does not exist
reasons Malformed There must be no more than 100 return reasons
reasons NotFound Return reason <reason> does not exist
resources Malformed There must be no more than 16.000 resources

return-rules.update

Updates a return rule. Any fields left out of the request will remain unchanged.

Request

Admin SDK
Admin.api('commerce.return-rules.update', request, function(response) { … });
HTTP POST
/api/v8/commerce.return-rules.update
{
  "id" : 7, // identifier of the rule to update (required) - int(1…)
  "rule" : { // rule's fields to update (required)
    "position" : 3, // position - int(1…)
    "name" : "...", // name - string(0…60)
    "allowReturns" : true, // indicates if returns are allowed - bool
    "approveAutomatically" : false, // indicates if allowed returns are automatically approved - bool
    "reasons" : [ 3, 6, 10, … ], // reasons (id) that the customer can choose (can be null) - int(1…)
    "maxDaysToReturn" : 30, // maximum number of days, from delivery date, to request a return - int(1…5000)
    "description" : { // description - string(2) -> string(0…1000)
      "en" : "...",
      "it" : "..."
    },
    "fromOrderDate" : "2020-01-01", // applied to orders from this order date (can be null) - date
    "toOrderDate" : "2020-12-31", // applied to orders up to this order date (can be null) - date
    "resources" : { // resources to which it is applied (can be null)
      "type" : "Product", // type of resources, can be "Product", "Department", "Producer" or "AttributeValue" - string
      "ids" : [ 287, 98, … ] // products, departments, producers or attribute values (id) - int(1…)
    },
    "customerType" : "Person", // customer to which it is applied (can be null), can be "Person" or "Company"
    "groups" : [ 5, 7, … ], // customer groups (id) to which it is applied (can be null) - int(1…255)
    "countries" : { // countries to which it is applied (can be null)
      "codes" : [ "UK", "IT", … ], // codes (ISO) of the countries - string(2)
      "refersTo" : "Shipping" // indicates if the codes refers to billing or shipping address of the order, can be "Billing" or "Shipping" - string
    }
  }
}

Response

{
  "status" : "ok"
}

Errors

Field Type Description
countries Malformed '<code>' is not a valid country code
countries Malformed A country code is repeated
countries NotFound Country '<code>' does not exist
groups Malformed There must be no more than 20 customer groups
groups NotFound Customer group <group> does not exist
id NotFound Return rule <id> does not exist
reasons Malformed There must be no more than 100 return reasons
reasons NotFound Return reason <reason> does not exist
resources Malformed There must be no more than 16.000 resources
update NotAvailable Return rules are not available for this installation

return-rules.delete

Deletes one or more return rules.

Request

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

Response

{
  "status" : "ok"
}