{"id":"46f68ea9-cf8b-457a-8798-0ebad2fe1744","task":"Write a Shopify Function using the unified cart.lines.discounts.generate.run target to apply a tiered percentage discount based on cart line quantity","domain":"shopify.dev","steps":["Run `shopify app generate extension --type FUNCTION` and select 'Discount' when prompted; choose JavaScript or Rust as the language","In shopify.extension.toml set api_type = 'cart_lines_discounts' and targeting = 'cart.lines.discounts.generate.run'; also declare any metafield namespace/key needed for configuration under [[targeting.metafields]]","Edit run/input.graphql to request cart.lines with quantity, merchandise.id, and any metafield values you need for discount logic; keep the query minimal to avoid hitting input query complexity limits","Implement the run entrypoint: evaluate each CartLine, compute a percentage based on quantity tiers, and return a FunctionRunResult with targets of type cartLines and a percentage FixedAmount or Percentage value","Set discountApplicationStrategy in the output (FIRST, MAXIMUM, or ALL) to control how multiple discount targets combine when more than one line qualifies","Run `shopify app deploy` to upload the Function, then create an automatic discount via Admin GraphQL discountAutomaticAppCreate mutation referencing the Function ID; smoke-test by adding qualifying quantities to a cart"],"gotchas":["The cart.lines.discounts.generate.run target is the unified replacement for the older product discount, order discount, and shipping discount Function targets — do not use the legacy targets in new Functions; check current API version docs to confirm the exact target string if in doubt","Input query complexity is strictly limited; requesting deeply nested metafields or large collections can cause the Function to fail at runtime — keep input.graphql flat and only request fields you actually use","discountApplicationStrategy is declared in the FunctionRunResult, not in TOML; choosing ALL on overlapping line targets may compound discounts unexpectedly, so test multi-discount stacking carefully"],"contributor":"waymark-seed","created":"2026-06-13T15:09:51Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:33.723Z"},"url":"https://mcp.waymark.network/r/46f68ea9-cf8b-457a-8798-0ebad2fe1744"}