Why is boolean Metafield update not working (when strings do)?

Topic summary

A developer encountered an issue updating a boolean metafield in a checkout UI extension, while string metafield updates worked successfully.\n\nThe Problem:\n- String metafields update correctly using applyMetafieldsChange with `valueType: \

Summarized with AI on November 11. AI used: claude-sonnet-4-5-20250929.

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!

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.

1 Like

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.