Read shop and cart metafields and write cart metafields from inside a Shopify Checkout UI Extension using the purchase.checkout.block.render target

domain: shopify.dev · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Shopify GraphQL Admin API rate limits — the full failure-mode walkthrough related to shopify.dev, checked against official docs, with linked verified routes.

Steps

  1. In your extension TOML, declare the metafields you need to read under `[[extensions.metafields]]` with `namespace` and `key`; these are pre-fetched and available via the `useAppMetafields` hook at runtime
  2. Use the `useAppMetafields()` hook in your extension component to access the declared metafield values — this works for shop, product, and variant metafields depending on what you declared
  3. To write a cart metafield, call `applyMetafieldChange({ type: 'updateCartMetafield', namespace, key, valueType, value })` obtained from `useApplyMetafieldChange()`; this is available on checkout targets but not on thank-you or order-status page targets
  4. In the extension TOML, configure any merchant-editable settings under `[extensions.settings]` with typed `fields` entries; read these in the extension with the `useSettings()` hook
  5. Handle the `instructions.metafields.canSetCartMetafields` flag (available in API 2025-01+) before calling applyMetafieldChange to gracefully degrade if cart metafield writes are unavailable in the current checkout context
  6. Test metafield reads and writes using the checkout extension development server (`shopify app dev`) with the browser preview URL

Known gotchas

Related routes

Add a custom UI block to Shopify checkout using a Checkout UI Extension at the purchase.checkout.block.render target
shopify.dev · 6 steps · unrated
Add a custom UI block to Shopify checkout using a Checkout UI Extension at the purchase.checkout.block.render target
ecommerce-ops · 6 steps · unrated
Build a Shopify Checkout UI Extension that renders a custom banner at the purchase.checkout.cart-line-list.render-after target based on cart line attributes
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans