Add dynamic rates or taxes to cart

Hi everyone,

Is there a recommended way to add custom, dynamic taxes or fees as separate line items in the Shopify checkout?

I need to use an external API to retrieve these specific calculated values (e.g., complex duties, regional service fees, etc.) and then display them clearly as ‘Taxes’ or ‘Fees’ so the customer sees a detailed breakdown before paying.

Which Shopify feature or API (e.g., Cart API, Checkout UI Extensions, etc.) would allow me to inject these external values into the final total before the order is paid?

Hi @GabrielTurnes

Have you looked into using Nested cart lines? This could be used within the context of a checkout extension to add additional charges visible throughout the buyer journey (cart, checkout, order confirmation, emails, etc.)

But this way it doesn’t appear as tax/duty within the order, right? I mean for reporting and graphing purposes.

And I’d like to add a tax/duty to the order as a whole, not item by item.

Is there any way to do that?

Correct - the nested cart lines wouldn’t appear by default as a tax or duty within the order - so for analytics purposes using the native reports, these wouldn’t be recognised as “true” taxes. If you used your own reporting, you could have these charges appear as taxes, but that might not be feasible here.

It does look like there is currently no supported way to inject a custom, externally-calculated tax or duty as a “true” tax line at the order level via the Admin API or Checkout UI Extensions.