Access metafields from Checkout UI extension

We are looking for a way to access order metafields from a Checkout UI extension.

Following suggestions from old threads like this and this we’ve tried to access it through a Storefront API query:

          query Order($orderId: ID!, $namespace: String!, $key: String!) {
            node(id: $orderId) {
              id
              ... on Order {
                metafield(namespace: $namespace, key: $key) {
                  value
                }
              }
            }
          }

But such requests fail with the error:

Access denied for order field. Required access: `unauthenticated_read_customers` access scope.

This can be the case as this access scope is not listed in the docs.

Therefore, I wonder if there is a way to retrieve order metafields client-side (thank-you target), without introducing a proxy for a back-end call?

Hey @edcode

Currently, during the checkout process, extensions can only use the useAppMetafields hook to access metafields for types of shop, customer, product, or variant. So no support for order metafields currently - although it is on the product teams radar. I believe you can create metafields tied to a checkout session and access them with this though: Metafields

Hey @Liam-Shopify,

Thank you for your suggestion. We have tried that, but, unfortunately, there are no shipping lines yet at the checkout stage to pull them through meta fields on the thank you page.