Cannot retrieve custom metaobjects with checkout theme extension

Cannot retrieve custom metaobjects with checkout theme extension

koiphish97
Shopify Partner
4 0 0

Hello Everyone,

I have configured my app to make custom metaobjects to be accessible via the storefront API. I am able to retrieve these custom metaobjects with my liquid theme extensions. However, when I try to retrieve them with a checkout theme extension, it seems to retrieve the metaobjects but they are empty.

 

koiphish97_0-1746426071759.png

 

Here it shows that the the metaobjects have been created for this test store and are accessible via the storefront:

 

koiphish97_1-1746426071668.png

 

koiphish97_2-1746426071683.png
 

Here is where I set the storefront access to PUBLIC_READ and enable them as “publishable”:

 

const METAOBJECT_VARIABLES = {
  definition: {
    name: "DonaSettings",
    type: "DonaSettings",
    access: {
      storefront: "PUBLIC_READ"
    },
    capabilities: {
      publishable: { enabled: true }
    },
    fieldDefinitions: [
      {
        key: "donateMealsChecked",
        name: "Donate Meals Checked",
        type: "single_line_text_field"
      },
      {
        key: "limitEnab......

Here is the logic of my theme extension for getting the metaobjects with a graphql query:

 

export default reactExtension(
  'purchase.checkout.block.render',
  () => <Extension />,
);

function Extension() {
  const [configData, setConfigData] = useState(null);
  const { query } = useApi();

  useEffect(() => {
    query(
      `
        query ($first: Int!, $type: String!) {
          metaobjects(first: $first, type: $type) {
            nodes {
              id
              handle
              fields {
                key
                value
              }
            }
          }
        }
      `,
      { variables: { first: 5, type: "DonaSettings" } }
    )

Here are the access scopes I have enabled:

[access_scopes]
# Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes
scopes = "read_orders, read_marketplace_fulfillment_orders, read_metaobjects, write_metaobjects, write_metaobject_definitions, unauthenticated_read_checkouts, unauthenticated_read_metaobjects"

Here is my extension toml:

 
api_version = "2025-01"

[[extensions]]
name   = "Checkout Badge"
handle = "donation-checkout"
type   = "ui_extension"

  [[extensions.targeting]]
  module = "./src/Checkout.jsx"
  target = "purchase.checkout.block.render"

  [extensions.capabilities]
  api_access = true

Any help would be much appreciated. Just not sure why the metaobjects query is returning as empty?

Thanks in advance!

Replies 0 (0)