I’m building a Shopify app that adds an “Order Protection” product to the cart with a price that should always be 4% of the cart subtotal (excluding the protection product itself).
Current Setup:
-
Protection product exists with handle order-protection
-
Product variant price is set to $0.00
-
I calculate 4% in the frontend and display it to customers
-
Multiple customers can checkout simultaneously
The Problem:
When I display the calculated fee (e.g., “$30 for a $750 cart”), it shows correctly in my UI. However, when the product is added to cart and appears in checkout, it still shows as “FREE” because the actual variant price is $0.
What I’ve Tried:
-
Line item properties - These display as metadata but don’t change the price shown
-
Updating variant price via Admin API - This creates race conditions when multiple customers order simultaneously (Customer A’s $4 fee gets overwritten by Customer B’s $8 fee)
What I Need:
A way to charge each customer 4% of their specific cart total without:
-
Race conditions from shared product pricing
-
Showing “FREE” in checkout
-
Requiring Shopify Plus (I’m on a standard plan)
Expected Behavior:
-
Customer A ($100 cart) sees and pays: Order Protection $4.00
-
Customer B ($200 cart) sees and pays: Order Protection $8.00
-
Both happening at the same time without conflicts
Question:
What’s the best approach to implement dynamic per-customer pricing for a single product in Shopify without race conditions? Is there a way to set line-item-specific prices, or do I need Shopify Functions (Plus only)?