Hello,
We’ve noticed a bug with attempting to apply order metafields in Checkout UI Extensions.
Applying a metafield change during checkout where a metafield value is already present will result in a false positive result.
Here’s a snippet of example code:
applyMetafieldsChange({
type: "updateMetafield",
key: "check_id",
namespace: "real_id",
value: check.id,
valueType: "string",
})
.then(() => {
console.log("Updated real_id.check_id metafield to : ", check.id);
console.log(
"Result: ",
metafields.find((mf) => mf.key == "check_id")?.value
);
})
.catch((e) => {
console.error(`Failed to update metafield`);
console.error(e);
});
If check_id in this example is bbbbbbb for example, then you’d expect the result to be bbbbbbb. Yet, we’re seeing this strange output from this code above:
Updated real_id.check_id metafield to : bbbbbbb
Result: aaaaaaa
It appears the applyMetafieldsChange doesn’t actually properly update the metafield nor does it throw an error in this case when the update failed.
Is there a special flag that needs to be passed to “force” an update?