Dynamic, Percentage-Based Tariff Surcharge at Checkout—Any Workarounds?

Hi Shopify Devs & Partners,

I’m an engineer with experience building Shopify Functions and Checkout UI Extensions, and I’m running into a hard limitation with dynamic surcharges at checkout.

Business Logic:

  • Apply a 30% tariff surcharge to all products with SKUs containing “DFCTO” in the cart.
  • Only apply the surcharge if:
    • The shipping country is the US.
    • The product is not bundled with a ring setting (custom logic based on custom attributes).
  • The surcharge must be dynamic (30% of the affected product(s) price), not a fixed fee.

What I’ve Tried:

  • Shopify Discount Functions: Only support positive values (discounts), which reduce the order total. Negative values (for surcharges) are not supported and will be ignored or treated as zero.
  • Cart Transform Functions: Can only decrease the price of cart lines (i.e., apply a discount), not increase it or add a fee.

Haven’t Tried:

  • Checkout UI Extensions: Can add/remove products/variants to the cart using useApplyCartLinesChange, but cannot dynamically set the price of a product/variant at checkout. The price must be set in the Shopify Admin.
  • Hidden Product Workaround: Not scalable for thousands of products with different prices, as you’d need a variant for every possible fee amount.
  • Third-party apps: Advanced Shipping Rules and Shipping Rates Calculator Plus can handle some country-specific surcharges, but not a true dynamic, per-product tariff as a line item.

What I Need:

  • A scalable, native way to add a dynamic, percentage-based fee or surcharge to the order total for arbitrary products at checkout.

Questions:

  • Is there any new pattern, API, or workaround for this use case?
  • Are there any roadmap updates for supporting dynamic surcharges or fees at checkout?
  • Has anyone built a production-ready workaround for this scenario?

Hi @Dan_Au

From digging into this, it does seem that Shopify Functions do not support adding dynamic surcharges or fees (i.e., increasing the order/cart total or line price) at checkout. All official Function APIs (Discount, Cart Transform, etc.) only allow you to reduce prices or block/validate, but not to add a fee or increase the price. Researching with help from some internal staff to see what would be the most reliable approach here.

Actually came up with a solution—though a little hacky. Created 2 extensions:

  1. update cart line items with a custom attribute _hasTariff:'true' based on condition shipping country is US and my other validations
  2. Create a cart transform function to use expand() to bundle a tariff product ($0) with new price of 30% of the qualifying product with _hasTariff attribute