Docs
Dashboard

Cart calculation and totals

Last updated View as Markdown

Cart calculation and totals

Cart amounts depend on more than unit price multiplied by quantity. Thor resolves the relevant price, discount applications, shipping, tax, and rounding for the cart’s context. Your storefront displays the result instead of maintaining a second commerce calculator.

What can change the result

Changing quantity can change line amounts and promotion eligibility. Changing address can change shipping options and tax. Changing customer or market can change prices and discounts. Removing a code can affect line, shipping, and total amounts together.

Request the fields needed by the affected screen from each mutation and use the returned cart. Do not update only the quantity label while leaving a cached total in place.

Show a clear breakdown

Render line amounts, applied discounts, shipping, tax, and total from their corresponding fields. Use the configured inclusive or exclusive tax convention consistently. Display each money value with its currency and fraction digits. See Money and rounding and Taxes.

A discount application records what actually applied. The presence of a discount code does not prove that it reduced the amount. A payment session likewise does not prove that an order has been paid.

Recover from changed conditions

Preserve the shopper’s choices when a price, stock, or eligibility error occurs. Read the latest cart, explain the affected item or step, and ask for any necessary correction before continuing. Do not keep displaying an old payable amount after the server rejects it.

See Build a cart and checkout for mutation sequencing and Recover from storefront errors for UI behavior.