Add custom data
Add custom data
Add a typed specs.wattage field to a product so a storefront can render a technical specification without parsing arbitrary text.
This example deliberately makes the definition public because wattage is buyer-facing information.
Before you begin
Use an existing product and Admin permissions for metafield definitions and product updates.
Check whether specs.wattage already exists for the product owner type.
If it does, verify its kind and reuse it.
See Metafields and metadata before choosing another data model.
1. Define the field
Keep the returned definition ID. For information not intended for buyers, use a private definition and verify the owner’s public surface before storing data. Neither metadata nor a public metafield is a place for credentials or internal business information.
2. Assign the value through the product
The integer is assigned using the typed integer member.
Do not encode it as text to bypass the definition.
Preserve other values according to the owner input’s documented update semantics.
3. Read through Storefront
Expect an integer value of 40 on the public product. If the field is absent, check the definition’s visibility, owner, assigned value, and product visibility before duplicating it elsewhere. To make the field a filter, follow Configure and render facets.