Catalog/commerce-cart-total

Commerce

Cart total (tax/discount/ship) API

Totals a cart with correct order-of-operations: line items -> order discount (pct then fixed) -> tax (exclusive add-on or inclusive extraction) -> shipping. Answers 'What is my cart total with tax and discount?', 'How much tax is baked into this gross price?'.

Price$0.02per request
MethodPOST
Route/v1/commerce/cart-total
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
commercecartcheckouttaxdiscountshippingtax-inclusivetotal
API URLhttps://x402.hexl.dev/v1/commerce/cart-total
Integration docs
Example request
{
  "lineItems": [
    {
      "name": "a",
      "unitPrice": 25,
      "qty": 2
    },
    {
      "name": "b",
      "unitPrice": 10,
      "qty": 1
    }
  ],
  "taxRatePct": 8.5,
  "orderDiscountPct": 10,
  "shipping": 5
}
Example response
{
  "lineItems": [
    {
      "name": "a",
      "unitPrice": 25,
      "qty": 2,
      "lineTotal": 50
    },
    {
      "name": "b",
      "unitPrice": 10,
      "qty": 1,
      "lineTotal": 10
    }
  ],
  "subtotal": 60,
  "orderDiscount": 6,
  "discountedSubtotal": 54,
  "taxRatePct": 8.5,
  "taxInclusive": false,
  "netGoods": 54,
  "tax": 4.59,
  "shipping": 5,
  "total": 63.59,
  "interpretation": "Subtotal $60 − discount $6 + tax $4.59 + shipping $5 = $63.59."
}
Input schema
{
  "type": "object",
  "required": [
    "lineItems",
    "taxRatePct"
  ],
  "properties": {
    "lineItems": {
      "type": "array",
      "examples": [
        [
          {
            "name": "a",
            "unitPrice": 25,
            "qty": 2
          },
          {
            "name": "b",
            "unitPrice": 10,
            "qty": 1
          }
        ]
      ]
    },
    "taxRatePct": {
      "type": "number",
      "examples": [
        8.5
      ]
    },
    "orderDiscountPct": {
      "type": "number",
      "examples": [
        10
      ]
    },
    "shipping": {
      "type": "number",
      "examples": [
        5
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}