Price and shipping adjust themselves to the measurement
With every measurement chosen, the price recalculates and a real variant is created in the store via API. Shipping is quoted live at the carrier, no fixed table.
The problem
A ready-made store works with shelf products: fixed size, fixed price. A blind is not like that: the price comes out of a formula with width, height, fabric, valance and control type, and the e-commerce platform has no field for that. In practice, the customer asked for a quote over WhatsApp and someone worked it out by hand.
Shipping had the same problem by a different route: a 1.50 m blind becomes a 155 cm tube, and the carrier configured in the store quoted R$ 8,911 per unit. It was not a bug, it was the package blowing past the limit of that shipping method.
What I built
- A configurator on the product page, in the store’s template, with the price updating at every choice of measurement, fabric, colour, valance and control type.
- A pricing and variant Worker, which applies the business rule and creates the variant via API so the configured item genuinely exists in the cart.
- Live shipping quotes: the Worker is registered in the store as a carrier and quotes at Braspress on the spot.
- Home card prices calculated from the value in the admin panel, so the owner adjusts in one place and all 17 products follow.
Technical decisions
Not escaping the platform’s checkout. A parallel cart would have broken coupons, shipping, reporting and the tax integration. Creating the variant on demand was more work up front and less trouble forever.
Carrier credentials never pass through the theme. The Worker is what talks to Braspress; username and password never reach the browser. If the quote fails, the shipping list comes back empty instead of an error: the buyer loses a delivery option, not the purchase.
Shipping dimensions declared, not calculated. The first version derived weight and volume from the piece’s area, but the operation packs everything into the same tube. I moved to declaring the real package, with the length coming from the blind’s width.
The pricing rule became a document before it became code. Every change to the formula goes into the documentation before the Worker, so there is a way to tell whether an odd price is a bug or the rule.
Tracking isolated in try/catch. The configurator skipped the platform’s analytics layer by using its own request. I added the event call by hand, isolated, because an analytics failure must not block a purchase.
How I verified it
The colour that vanished from the order. The owner noticed an order without the chosen colour. I ran the configurator’s calculation on three product pages: all three returned the name without the colour, since a change six weeks earlier when each colour became a separate product. The redirect to the colour’s page was clearing the selector.
The fix moved to deriving the colour from the URL, not the product name: the manual already asks not to touch URLs, but the name changes for SEO, and matching by name would make the colour disappear again. I validated on the real pages, deliberately including two similarly-named colours.
The surcharge that looked like it was growing. An add-on showed as ”+ R$ 98.00/m” on a 1.40 m blind, suggesting a rate that climbed with size. I compared the price with and without the accessory at three widths: the difference divided by width gave the same rate all three times. The calculation was right, only the label was wrong.