Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hi Baam,
To save a variable to a Customer metafield with the key 'Time', you can use the customer
mutation, it would look something like:
mutation UpdateCustomerMetafield {
customerUpdate(input: {
id: "gid://shopify/Customer/1234567890123", # Replace with the actual customer ID
metafields: [
{
namespace: "custom_namespace", # Replace with your namespace
key: "Time",
value: "2023-10-03T15:18:59.106Z", # Replace with the value you want to save
type: "date_time" # Ensure the type matches the value format
}
]
}) {
customer {
id
metafields(first: 5) {
edges {
node {
namespace
key
value
type
}
}
}
}
userErrors {
field
message
}
}
}
In this example:
"gid://shopify /Customer /1234567890123"
with the actual customer ID."custom _namespace"
with the appropriate namespace for your metafield.value
with the actual value you want to save to the metafield.type
matches the format of the value you are saving.Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog