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

What purpose does Shopify functions not support additional fees, is it to not mislead a customer price at checkout? If a company includes tariff fees in the product it seems misleading without a corresponding line item description. There are tons of businesses that would benefit from any upsell like: gift wrapping, disposal fees for oil/tires, protection plans for physical or digital items, and ESPECIALLY for tariffs.

We are incurring 10% tariff increase passed on from the manufacturer and are splitting it 50/50 with the customer… so we needed a 5% tariff on each cart subtotal. I was looking into checkout extensions or meta objects but Dan’s solution seems like the most viable from research. I was able to accomplish 5% tariff on cart subtotals with the Zonos app, though pricey. Our 5% tariff fee will be removed when the federal govt returns to normal tariff numbers. We are 50/50 domestic and import for apparel materials, so I assume many others are in the same boat across multiple industries.

Almost every other tariff app places a % on each item, or adds an item to cart that calculates 5% based on subtotal. Both of those methods are sub-optimal for scaling, or add terrible duplication on the cart and checkout pages.

Please add cart percentages to the current tariff/duties slot, it would be useful to many many businesses.