--- title: useApplyMetafieldsChange description: Returns a function to mutate the `metafields` property of the checkout. api_version: 2023-07 api_name: checkout-ui-extensions source_url: html: >- https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/metafields/useapplymetafieldschange md: >- https://shopify.dev/docs/api/checkout-ui-extensions/2023-07/react-hooks/metafields/useapplymetafieldschange.md --- # use​Apply​Metafields​Change Returns a function to mutate the `metafields` property of the checkout. ## use​Apply​Metafields​Change() ### Returns * **(change: MetafieldChange) => Promise\** ### MetafieldChange ```ts MetafieldRemoveChange | MetafieldUpdateChange | MetafieldRemoveCartChange | MetafieldUpdateCartChange ``` ### MetafieldRemoveChange Removes a metafield. * type The type of the \`MetafieldRemoveChange\` API. ```ts "removeMetafield" ``` * key The name of the metafield to remove. ```ts string ``` * namespace The namespace of the metafield to remove. ```ts string ``` ### MetafieldUpdateChange Updates a metafield. If a metafield with the provided key and namespace does not already exist, it gets created. * type The type of the \`MetafieldUpdateChange\` API. ```ts "updateMetafield" ``` * key The name of the metafield to update. ```ts string ``` * namespace The namespace of the metafield to add. ```ts string ``` * value The new information to store in the metafield. ```ts string | number ``` * valueType The metafield’s information type. ```ts "string" | "integer" | "json_string" ``` ### MetafieldRemoveCartChange Removes a cart metafield. * type The type of the \`MetafieldRemoveChange\` API. ```ts "removeCartMetafield" ``` * key The name of the metafield to remove. ```ts string ``` * namespace The namespace of the metafield to remove. ```ts string ``` ### MetafieldUpdateCartChange Updates a cart metafield. If a metafield with the provided key and namespace does not already exist, it gets created. * type The type of the \`MetafieldUpdateChange\` API. ```ts "updateCartMetafield" ``` * metafield ```ts { key: string; namespace: string; value: string; type: string; } ``` ### MetafieldChangeResult ```ts MetafieldChangeResultSuccess | MetafieldChangeResultError ``` ### MetafieldChangeResultSuccess * type The type of the \`MetafieldChangeResultSuccess\` API. ```ts "success" ``` ### MetafieldChangeResultError * type The type of the \`MetafieldChangeResultError\` API. ```ts "error" ``` * message A message that explains the error. This message is useful for debugging. It is \*\*not\*\* localized, and therefore should not be presented directly to the buyer. ```ts string ``` ## Related [APIs - StandardApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/standardapi) [APIs - CheckoutApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/checkoutapi) [APIs - OrderStatusApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/orderstatusapi) [APIs - CartLineItemApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/cartlineitemapi) [APIs - PickupPointListApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/pickuppointlistapi) [APIs - PickupLocationListApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/pickuplocationlistapi) [APIs - ShippingOptionItemApi](https://shopify.dev/docs/api/checkout-ui-extensions/apis/shippingoptionitemapi) [APIs - ExtensionTargets](https://shopify.dev/docs/api/checkout-ui-extensions/apis/extensiontargets)