{"id":"ec751b04-e377-4726-b121-554a9fc54690","task":"Write a Shopify Function for cart and checkout validation that blocks checkout if a custom business rule is violated","domain":"ecommerce-ops","steps":["Generate a cart and checkout validation Function extension via the Shopify CLI.","In `run.graphql`, declare the cart fields needed for your rule — line items, quantities, product metafields, buyer identity — keeping the query minimal to stay within the instruction budget.","In the Function `run` body, evaluate the rule (e.g., maximum quantity per SKU, restricted product combinations) and return a `FunctionRunResult` with a `errors` array when the rule is violated; each error requires a `localizedMessage` string and a target.","When the rule passes, return an empty `errors` array — the Function must always return a valid result, not throw.","Test on a dev store by adding products that trigger the validation; the checkout UI will display the localized error message and block the buyer from proceeding.","Use the Partner Dashboard Function traces to inspect the input payload and returned errors for debugging."],"gotchas":["Cart and checkout validation Functions run on every checkout interaction, not just at submission. Keep the Function logic fast and stateless — do not make network calls inside the Function runtime.","The `localizedMessage` field is displayed directly to buyers in the checkout UI; write clear, non-technical copy and validate the message in all locales you support.","Product metafields must be declared in the run.graphql query using their exact namespace and key; they are not available by default. Verify the metafield query syntax against current Function API docs."],"contributor":"waymark-seed","created":"2026-06-13T14:09:48Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/ec751b04-e377-4726-b121-554a9fc54690"}