New Shopify Certification now available: Liquid Storefronts for Theme Developers

Metafield definition and access settings, this is a big problem

Next_Cart
Shopify Partner
1 0 2

We are migrating products from our client's online store to Shopify using the latest API version 2023-10. The product attributes are migrated as metafields, and we just noticed a serious problem with metafield definition and access settings since the API version 2023-01 to 2023-10.

 

There are some issues/limitations:

  • The namespace is required to be the app reserved namespaces. You cannot create a metafield definition in a custom namespace without the app reserved prefix, this is the error: "Setting access controls on a definition under this namespace is not permitted".
  • The store owner cannot change the metafield definitions once they are imported. You can only delete the metafield definitions through the app you used to import them, but this will not work with custom apps.
  • The access "MERCHANT_READ_WRITE" is the only setting you can use if you want to be able to view and edit the metafields via admin. This leads to a problem: one year later, if the store owner wants to use another app to interact with the metafields, or copy data to another store, you'll need to go back and grant access to that app. But, this becomes impossible if the metafield definitions were imported via a custom app and that custom app was removed for some reason.

Shopify developers, e-merchants, web agencies and developers should take note of thess issues. I hope you will find out a comprehensive solution.

Replies 5 (5)
JohnBerry
Shopify Staff
Shopify Staff
6 3 4

Hello,

 

You should be able to create a metafield definition in a non app reserved namespace (e.g. "custom") as long as you are not setting a value for the access input. If you do not use a reserved namespace, the merchant and other apps should be able to edit the definition and set metafield values.

To learn more visit the Shopify Help Center or the Community Blog.

homerjam
Shopify Partner
1 0 0

How should I go about creating a definition in a "custom" namespace with storefront access??

 

EDIT/UPDATE:

 

So it seems that creating the namespace with "$app:custom" is the answer

JohnBerry
Shopify Staff
Shopify Staff
6 3 4

That is correct. Prefixing a namespace with "$app:" produces a metafield definition in a reserved namespace that is owned by the app that created it. The owning app has full control over the definition including the definition's admin and storefront access settings.

 

Apps can also create non-reserved namespace metafields (e.g. "custom") but cannot set storefront or admin access. In the 2024-01 API release and beyond, storefront access for non-reserved namespace metafields can only be set from within the Admin.

To learn more visit the Shopify Help Center or the Community Blog.

m4rc
Shopify Partner
2 0 3

@JohnBerry 

Do you know we will be able to create non-reserved namespace metafields for any owner type?

 

I would like to create a shop metafield as a non-reserved namespace metafields, but it seems like there's no way to currently define it from the Shopify Admin.

JohnBerry
Shopify Staff
Shopify Staff
6 3 4

Shop metafields can be created using the metafieldDefinitionCreate Admin API mutation with an ownerType = SHOP.

 

Shop metafields cannot be created through the Admin interface.

To learn more visit the Shopify Help Center or the Community Blog.