Dev.to WebDev ๐Ÿ›  Dev ๐Ÿ‘ 2 ๐Ÿ“– 2 min read

Syncing Shopify prices to a live commodity rate: lessons from building a gold-price app

TL;DR: If you tie Shopify prices to a live rate (gold, silver, currencies, supplier costs), store the pricing inputs per variant, batch your writes, skip tiny changes, and put guardrails before any automatic sync. We bu

TL;DR: If you tie Shopify prices to a live rate (gold, silver, currencies, supplier costs), store the pricing inputs per variant, batch your writes, skip tiny changes, and put guardrails before any automatic sync.

We build Live Metal Auto Price Updater, a Shopify app that reprices jewelry from live gold, silver and platinum rates. Here are the engineering problems that turned out to matter more than the pricing math.

1. Store the inputs per variant, not the price

The price is derived, so don't treat it as the source of truth. Store the inputs (metal type, weight, purity, stone value, making charge) as metafields on each variant or product, and calculate the price from those plus the current rate. Then a rate change is just a recalculation, and you never lose the reasoning behind a price.

2. Batch your writes

A store can have thousands of variants. Updating them one request at a time is slow and burns through API rate limits. Shopify's GraphQL Admin API can update several variants of a product in one call (productVariantsBulkUpdate). Group your changes by product, and throttle based on the query cost the API reports back instead of a fixed delay.

3. Skip changes too small to matter

If gold moves 0.05%, repricing 3,000 variants by a few cents creates API load and noisy price history for no benefit. Set a threshold (for example 0.5%), and only write when the new price differs from the current one by more than that.

4. Guardrails before automation

Bad rate data happens: a feed outage, a unit mix-up (ounces vs grams), a currency error. Before any write:

  • reject rates that move more than a set percentage from the last good value
  • enforce a per-product price floor (a stop-loss)
  • log every change so it can be rolled back

5. Give merchants a review mode

Many merchants want to see the new prices before they go live, at least at first. A "review then sync" mode, with auto-approve as an opt-in, earned more trust than any feature we built.

6. Rounding is a product decision

Jewelers often want prices ending in 9 or rounded to the nearest 10. Apply rounding last, after floors and thresholds, so it can't push a price under the floor.

The pricing formula, for reference

Most gold jewelry is priced as: metal weight ร— live rate ร— purity + making charges + stone value + margin, where purity is karat รท 24 (22K โ‰ˆ 0.917, 18K = 0.75, 14K โ‰ˆ 0.583).

If you're building anything that ties prices to an external feed, the same patterns apply. Happy to answer questions in the comments.

Live Metal Auto Price Updater is on the Shopify App Store: https://apps.shopify.com/live-metal-auto-price-updater

๐Ÿ“ฐ Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.