For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
I'm building a checkout UI extension and am able to update the order metafield using a string ("Yes" or "No") with the following code:
const checkValue = value ? "Yes" : "No";
applyMetafieldsChange({ type: "updateMetafield", namespace: metafieldNamespace, key: metafieldKey, valueType: "string", value: checkValue, });
However, trying to update a different, boolean, metafield with the following settings does not work:
applyMetafieldsChange({ type: "updateMetafield", namespace: metafieldNamespace, key: metafieldKey, valueType: "boolean", value, });
The metafields and toml are correctly set up with both metafield's namespace / key. The value on the latter code comes from the props of the onChange attribute, whereas on the former code uses this value with a ternary operator to convert to strings.
Why does the second one not update the metafield? Am I missing something?
Thanks!
Solved! Go to the solution
This is an accepted solution.
Hey @no_robotocha
The applyMetafieldsChange
function currently only supports 'integer', 'string', and 'json_string' as value types. As a workaround you could consider storing it as a string or integer and then converting it back to a boolean in your code.
Scott | Developer Advocate @ Shopify
This is an accepted solution.
Hey @no_robotocha
The applyMetafieldsChange
function currently only supports 'integer', 'string', and 'json_string' as value types. As a workaround you could consider storing it as a string or integer and then converting it back to a boolean in your code.
Scott | Developer Advocate @ Shopify
Okay great, using a string and dealing with it programmatically later is exactly what I've done but I'm happy to know the reason for my issue! Thanks @SBD_ - Do you know where I could read more about the functions, I've had a look and can't seem to find them other than references within guides.
Great!
Yeah they're tricky to find. I only came across these references. We could do a better job with this.
Scott | Developer Advocate @ Shopify