Estimate Cart

Using the Estimate Cart endpoint you can discover the estimated totals and available shipping methods for any combination of Sku’s and a shipping address. This feature can be useful for debugging failed carts where one or more Sku’s may have been unavailable in a certain region or no shipping methods were returned for an address.

Cart estimation is not a part of the checkout process and is instead best used as a method for anticipating the behavior of a cart or debugging a failed cart.

When using Estimate Cart you do not need to manage the lifecycle of a cart. Violet will handle the creation, modification, and deletion of any external carts that may need to be created while estimating a cart.

When the Estimate Cart process fails in the external commerce platform, Violet will attempt to parse and surface all error messages from the external system so that you are able to fully understand why the estimation failed. The most common reasons for failure will be Sku unavailability and incorrectly formatted shipping addresses.

Estimate Cart

post
Header parameters
X-Violet-TokenstringRequired
X-Violet-App-SecretstringRequired
X-Violet-App-Idinteger · int32Required
Body

Calculate Cart Request

base_currencystring · enum · min: 3 · max: 3Optional

The base currency the cart should be calculated in.

Default: USDPossible values:
Responses
200
success
application/json
post
POST /v1/carts/estimate HTTP/1.1
Host: sandbox-api.violet.io
X-Violet-Token: text
X-Violet-App-Secret: text
X-Violet-App-Id: 1
Content-Type: application/json
Accept: */*
Content-Length: 225

{
  "base_currency": "USD",
  "skus": [
    {
      "sku_id": 10000,
      "quantity": 2
    }
  ],
  "shipping_address": {
    "address_1": "2815 Elliott Ave",
    "address_2": "Unit 100",
    "city": "Seattle",
    "state": "WA",
    "country": "US",
    "postal_code": "98121",
    "phone": "1234567890"
  }
}
{
  "estimated_carts": [
    {
      "merchant_id": 10000,
      "platform": "SHOPIFY",
      "base_currency": "USD",
      "sub_total": 19998,
      "shipping_total": 0,
      "tax_total": 2119,
      "total": 22117,
      "skus": [
        {
          "quantity": 2,
          "sku_id": 10000,
          "name": "Nintendo Entertainment System",
          "price": 9999,
          "merchant_id": 11111,
          "external_id": "31516807528534",
          "available": true,
          "requires_shipping": true,
          "product_type": "PHYSICAL",
          "line_price": 19998
        }
      ],
      "available_shipping_methods": [
        {
          "label": "Free Shipping",
          "carrier": "OTHER",
          "price": 0,
          "shipping_method_id": "18ff5c0a16d83cb8ba46848e48e06532"
        },
        {
          "label": "Ground Advantage",
          "carrier": "USPS",
          "price": 712,
          "shipping_method_id": "468c823c817c753e850ff6658ef1480f"
        },
        {
          "label": "Priority Mail",
          "carrier": "USPS",
          "price": 934,
          "shipping_method_id": "02ef65ebff687faa10c71830d41144b2"
        },
        {
          "label": "Standard",
          "carrier": "OTHER",
          "price": 1990,
          "shipping_method_id": "7a4763e6b861a281511834b449e0c574"
        }
      ],
      "has_shipping_methods": true
    }
  ]
}

Last updated

Was this helpful?