For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
In my Checkout UI extension, I can update order metafields without any problem. But I can't update customer metafield.
For example,
useApplyMetafieldsChange
({
type: "updateMetafield",
namespace: "order_details",
key: "delivery_date",
valueType: "string",
value,
});
useApplyMetafieldsChange
({
type: "updateMetafield",
namespace: "custom",
key: "cust_test",
valueType: "integer",
value,
});
doesn't work (here custom is a namespace under customer.metafields).
For order metafields, they work fine even without matching [[extensions.metafields]] in the shopify.extension.toml file. I added
[[extensions.metafields]]
namespace = "custom"
key = "cust_test"
in shopify.extension.toml, but I still can't read or write this meta data. The app can access protected customer data, e.g. shipping zip code.
Am I still missing something, or if there is some kind of access permission I have to setup?
Thanks for your help.
--Jude
Solved! Go to the solution
This is an accepted solution.
Hi there 👋
The useApplyMetafieldsChange hook only updates metafields on the Checkout object. Once the checkout is completed the metafields are present on the resulting order. At this time during the checkout process order metafields are the only metafield that you can modify directly.
Instead of adding a metafield to the customer during the checkout process, this could be something that is done after the order is created. You could respond to webhooks for orders that have been created, and then add the webhook to the customer.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hi there 👋
The useApplyMetafieldsChange hook only updates metafields on the Checkout object. Once the checkout is completed the metafields are present on the resulting order. At this time during the checkout process order metafields are the only metafield that you can modify directly.
Instead of adding a metafield to the customer during the checkout process, this could be something that is done after the order is created. You could respond to webhooks for orders that have been created, and then add the webhook to the customer.
To learn more visit the Shopify Help Center or the Community Blog.
Apologies for reopening this. But I was wondering if you could elaborate on this with code or a link to documentation that does this:
Instead of adding a metafield to the customer during the checkout process, this could be something that is done after the order is created. You could respond to webhooks for orders that have been created, and then add the webhook to the customer.
Thanks
Is it accurate to say that there is currently no capability to update customer metafields through a Checkout extension in Shopify?
@lizk , Do we have any updates on this? When can we expect it to be available for all metafield resources on the checkout?