# metafield_definitions

> The metafields the products and the cart ask Shopify for, for each kind of `[metafield]` element on the page (add the ones a script reads, remove the ones nobody shows). Synchronous: it cannot stop, and an error it throws is logged and the filter skipped.

Status: Ready (Smootify 2.0)  
URL: https://www.smootify.io/docs/reference/api/filters/metafield-definitions  
Updated: 2026-10-13

The metafields the products and the cart ask Shopify for, for each kind of `[metafield]` element on the page (add the ones a script reads, remove the ones nobody shows). Synchronous: it cannot stop, and an error it throws is logged and the filter skipped.

Add it with `Smootify.addFilter`: answer the value changed, nothing to keep it, or `false` to stop.

```ts
metafield_definitions: ( definitions: MetafieldIdentifier[], context: MetafieldDefinitionsContext, ) => MetafieldIdentifier[] | undefined
```

## Types

### MetafieldIdentifier

```ts
export interface MetafieldIdentifier {
  namespace: string;
  key: string;
}
```

### MetafieldDefinitionsContext

```ts
/** Who asks for the definitions, with the attribute and the selector of those elements. */
export interface MetafieldDefinitionsContext {
  /**
   * What asks for the definitions: the products (`[metafield]` in `smootify-product`), their variants
   * (`[variant-metafield]`) or the products of the cart lines (`[metafield]` in `cart-item`).
   */
  scope: "product" | "variant" | "cart";
  attribute: "metafield" | "variant-metafield";
  selector: string;
}
```
