order

order.calculate

Calculates the total cost of an order for a given customer and a set of products, as well as the available shipping methods based on the specified address. The calculation takes into account store product prices, discounts, taxes, shipping costs, and other store settings. The result includes a detailed breakdown of the final order cost by its components.

Note that the final totals, taxes, and other amounts must include the corresponding values for the selected shipping method.

The result of this method can be used when creating an order using the order.add method.

post/order.calculate.json

Request

  • Base URL: https://api.api2cart.com/v1.1
  • URL: https://api.api2cart.com/v1.1/order.calculate.json
  • Auth: API key in header x-api-key and API key in header x-store-key

Request body

customer_emailstring required

Defines the customer specified by email for whom the order needs to be calculated

currencystring

Defines currency code

currency_idstring

Currency Id

store_idstring

Store Id

couponsstring[]

Coupons that will be applied to order. If the order isn't eligible for any given discount code or there is no discount with such a code it will be skipped during calculation

rounding_precisioninteger
<p>Specifies the rounding precision for fractional numeric values (such as prices, taxes, and weights).</p> <p>Supported values range from <b>1</b> to <b>6</b>.</p> <p>The default rounding precision may vary depending on the platform. You can retrieve the default value using the <strong>cart.info</strong> method in the <code>default_rounding_precision</code> field. </p><p>Values are rounded to the nearest number at the specified precision. Fractions of .5 or higher are rounded up, while fractions lower than .5 are rounded down.</p>
shipp_first_namestring required

Specifies shipping first name

shipp_last_namestring required

Specifies shipping last name

shipp_address_1string required

Specifies first shipping address

shipp_address_2string

Specifies second address line of a shipping street address

shipp_citystring required

Specifies shipping city

shipp_postcodestring required

Specifies shipping postcode

shipp_statestring

Specifies shipping state code

shipp_countrystring required

Specifies shipping country code

shipp_companystring

Specifies shipping company

shipp_phonestring

Specifies shipping phone

bill_first_namestring

Specifies billing first name

bill_last_namestring

Specifies billing last name

bill_address_1string

Specifies first billing address

bill_address_2string

Specifies second billing address

bill_citystring

Specifies billing city

bill_postcodestring

Specifies billing postcode

bill_statestring

Specifies billing state code

bill_countrystring

Specifies billing country code

bill_companystring

Specifies billing company

bill_phonestring

Specifies billing phone

response_fieldsstring

Set this parameter to choose which entity fields to retrieve. Use comma-separated field names in curly braces, nested to match the response structure, e.g. {result{product{id,name}}}. The wildcard * returns every field at a level: {} gives the whole response, {result{product{}}} all product fields.

idempotency_keystring

A unique identifier associated with a specific request. Repeated requests with the same <strong>idempotency_key</strong> return a cached response without re-executing the business logic. <strong>Please note that the cache lifetime is 15 minutes.</strong>

Example request

{
  "customer_email": "jubari@hannsgroup.com",
  "currency": "USD",
  "currency_id": "usd",
  "store_id": "1",
  "rounding_precision": 3,
  "shipp_first_name": "John",
  "shipp_last_name": "Smith",
  "shipp_address_1": "Green str. 35",
  "shipp_address_2": "Green str. 35",
  "shipp_city": "Chicago",
  "shipp_postcode": "24545",
  "shipp_state": "IL",
  "shipp_country": "US",
  "shipp_company": "Apple",
  "shipp_phone": "880086544564",
  "bill_first_name": "Adam",
  "bill_last_name": "Smith",
  "bill_address_1": "Green str. 35",
  "bill_address_2": "Red str, 2",
  "bill_city": "Chicago",
  "bill_postcode": "12345",
  "bill_state": "IL",
  "bill_country": "US",
  "bill_company": "Apple",
  "bill_phone": "8 800 5659 6896",
  "response_fields": "{result}",
  "idempotency_key": "098f6bcd4621d373cade4e832627b4f6",
  "order_item": [
    {
      "order_item_id": "125, where {x} - 1,2,3,... etc",
      "order_item_parent": 2,
      "order_item_parent_option_name": "Internal Memory Storage",
      "order_item_option": [
        {
          "order_item_option_name": "Color",
          "order_item_option_value": "green"
        }
      ]
    }
  ]
}

Response

successful operation

return_codeinteger
return_messagestring

Changes

No recorded changes to this operation across all 1 revision of this API.