{"slug":"normalize-prices-update-cart","title":"Normalize displayed prices and update a cart snapshot","label":"Shopping data cleanup","description":"Parse prices with an explicit locale, apply guarded JSON changes, and reconcile a supplied cart with exact arithmetic.","problem":"Displayed prices may use different decimal separators, and an agent can overwrite the wrong cart entry if it applies an unguarded change. Normalize prices first, then test the expected record before editing its snapshot.","steps":[{"tool":"commerce.money-parse","title":"Read the price with its declared format","text":"Supply a supported locale, currency and decimal scale. For example, 1.234,56 € with de-DE, EUR and two decimal places becomes 1234.56. Check each returned valid flag; ranges, prose, conflicting currency tokens and excess precision remain errors. A shared $ symbol does not establish which dollar currency the merchant uses."},{"tool":"data.json-patch","title":"Guard changes to the supplied snapshot","text":"Use a test operation on the expected SKU or currency before replacing a price or quantity. Map only a valid normalized amount into the patch value. Array additions insert at an index; /- appends. If any operation fails, no result is committed and the original supplied snapshot is unchanged. This tool does not write to a merchant cart or place an order."},{"tool":"commerce.price-components","title":"Recalculate explicit components","text":"Map the updated snapshot into the item schema, including unitPrice, quantity and discount. Supply the same declared currency and decimal scale. Keep unavailable shipping, tax and fees as null. A known subtotal is not a complete checkout total until every component is supplied."}],"outcome":"Normalized price strings, a guarded JSON snapshot and an exact reconciliation. Each operation is a separate call; currency selection, product identity and permission to modify a real cart remain the caller's responsibility.","url":"https://agent-utilities.agent-utilities.workers.dev/use-cases/normalize-prices-update-cart","apiUrl":"https://agent-utilities.agent-utilities.workers.dev/v1/content/workflows/normalize-prices-update-cart","estimatedMicroUsd":1300,"pricingScope":"One successful call per listed step. Each call bills separately; check current prices before executing."}