Learn how to define and use metafields in Spree Commerce
Metafields in Spree allow you to attach custom data to nearly any object in your store - without needing to write a single line of code or modify the database.From product materials to internal order notes, metafields give you the flexibility to store, manage, and display extra information that doesn’t come out of the box. This reduces reliance on developer deployments, makes experimentation easier, and enables faster iteration directly from the admin dashboard.
To create a metafield definition go to Settings → Metafield DefinitionsHere you’ll see a list of all existing metafield definitions in your store. To add a new one, click New Metafield Definition in the top right corner.Fill out the form with the required details:
Name - this is the display name for the field, shown in the dashboard and/or storefront
Namespace - used to group metafields and avoid naming conflicts
We recommend using something like “custom” for internal or merchant-defined fields
Avoid using common Spree model names like product, order, or variant as these may conflict with existing integrations
Key - the unique identifier for the field, combined with the namespace
e.g.: custom.material, custom.internal_note
Resource - choose the object the metafield applies to (see full list below)
Type - the format of data the field should accept (see examples below)
Display on - choose whether this field appears in the Admin only, or Admin and Storefront.
Each metafield must be assigned a type, which determines the format of the stored value. Choosing the right type helps keep data structured, valid, and useful across the storefront and admin.
Short Text - for single-line strings, e.g., “Cotton” or “Blue”
Long Text - multi-line content, e.g., care instructions
Rich Text - text with formatting options, e.g., marketing blocks
Number - any numeric value, e.g., 4.5 (rating), 12 (inches)
First, navigate to the relevant resource (e.g., Product, Order, Shipment).Click the three-dot menu in the top right corner and select Metafields from the dropdown.Enter the desired values in the form and click Save to finalized your changes.This works for any individual resource type and is perfect for adding or editing a few metafields manually.
Product metafields can also be imported or updated in bulk by:
Adding columns to your CSV file using this format: metafield.namespace.key (e.g. metafield.custom.material)
Entering the desired values for each product row.
Importing the file when uploading a new product catalog
You can also update your existing catalog by exporting the product file, updating it as described above, and then reimporting it to apply metafield updatesThis is ideal for large-scale changes across multiple products, especially when onboarding a large catalog.