Skip to main content

Cost API

The Cost API provides access to the cost breakdown of the current checkout, including subtotal, shipping, tax, and total amounts. Use this API to display order summaries, track spending thresholds, and show cost-related information to the buyer.

All cost values are read-only. There are no methods to modify pricing from a checkout extension.

Some values are conditionally available. totalShippingAmount is undefined until the buyer selects a shipping method, and totalTaxAmount is undefined when taxes haven't been calculated or aren't available for the buyer's region.

  • Display an order cost summary: Show the buyer a breakdown of subtotal, shipping, tax, and total amounts.
  • Show progress toward free shipping: Compare the cart subtotal against a threshold and display how much more the buyer needs to spend.
  • Track spending thresholds: Use the subtotal or total amount to trigger conditional UI based on cart value.
Support
Targets (31)

The shopify global object provides cost data for the current checkout. Access the following properties on shopify to read the cost breakdown. Available to purchase extension targets.

required

The cost breakdown for the current checkout, including subtotal, shipping, tax, and total amounts. These values update as the buyer progresses through checkout and costs like shipping and tax are calculated.


  • Label totalAmount as an estimate on early steps: The totalAmount excludes costs not yet negotiated, such as delivery fees before a shipping method is selected. On steps where costs are incomplete, label the value accordingly (for example, "Estimated total") so the buyer understands the final amount might change.
  • Use subtotalAmount for threshold calculations: The subtotal is always available and reflects the value of items in the cart, making it a reliable basis for free shipping thresholds or minimum order checks.

Was this page helpful?