Update product metafield

The Update product metafield action adds a metafield to the product that triggers the workflow, or updates an existing metafield on that product.

Fields

The Update product metafield action contains the following fields.

Fields used in actions that update metafields.
FieldDescription
MetafieldRequired. This dropdown selects a metafield by name or by namespace and key.
NamespaceRequired when selecting an unstructured metafield. A namespace is a container for a group of metafield definitions. Grouping metafields within a namespace prevents your metafields from conflicting with other metafields.
KeyRequired when selecting an unstructured metafield. A key is an identifier for the metafield definition.
TypeRequired when selecting an unstructured metafield. The data type of the metafield's value.
ValueThe value is the information to be stored in the metafield. Format the value according to its data type to avoid errors when the workflow runs.

Triggers

The Update product metafield action requires a field, Product ID, that identifies the product to add a metafield to. The product ID is set by default and can't be changed. The Update product metafield action can be used in workflows that start with the following triggers:

API details

To learn more, review the MetafieldInput input object.

Templates

Convert tags with a prefix to a product metafield using the Run code action

This workflow will take tags that start with a prefix such as 'color:' and add them to a product metafield list. It uses the Run code action to parse the tags and existing items in the metafield list. The workflow runs when a product is created, but can be manually run on existing products. View template

Tag and organize new products by title

Standardize tagging, merchandising, and care instructions for new products based on product title. View template

Track product variants that are on sale using a product metafield

Sets a metafield on a product if at least one of its variants is on sale. This can be useful for tracking which products are currently on sale. View template

Update a product metafield if a product tag has a certain prefix

When a product is added to store, check if any product tags contain "prefix_" and then add the rest of the tag as a product metafield. View template

Can’t find the answers you’re looking for? We’re here to help.