Public metafields
Public metafields expose product group data to your theme’s Liquid, the Shopify Storefront API, and any other app that reads product metafields. This is the only data Color Swatches publishes through this surface; variant swatches and other features stay internal to the app and its theme widget.
By default this group data lives in private (app-scoped) metafields that only Color Swatches itself can see. Turn the setting on when you want to render group swatches with your own Liquid, query them from a headless storefront, or share them with a search, filter, or SEO app.
Enabling public metafields
Section titled “Enabling public metafields”- In the Color Swatches admin, go to Settings → Product groups → General.
- Check Enable public metafields and save.
Saving triggers a full resync that writes every group to the public namespace. Small catalogues finish in under a minute; very large ones take longer.
You can disable the setting at any time. The public copies are removed, the private metafields stay in place, and the app keeps working without further changes.
What gets written
Section titled “What gets written”The toggle controls a single product metafield:
- Namespace:
pl_swatches - Key:
groups - Type: JSON
- Owner: Product
In the Shopify admin you’ll find the definition under Settings → Custom data → Products, listed as “Platmart Swatches: Groups (public)”.
Only products that belong to at least one group get this metafield.
Payload structure
Section titled “Payload structure”The metafield value is always a JSON array, with one element per group the product belongs to. A product in a single-option group looks like this:
[ { "group_id": 12345, "option_name": "Color", "type": "colors", "display_for": "products_and_collections", "linked": false, "swatches": [ { "handle": "backpack-black", "name": "Black", "type": "one_color", "color_one": "#000000", "color_two": null, "image": null, "out_of_stock": false } ] }]If the product belongs to several groups, the array has multiple elements. Multi-option groups expand to one element per option slot, each with the same swatches shape.
Reading from Liquid
Section titled “Reading from Liquid”To render group swatches in your theme, see Reading swatch data in Liquid.
Reading from the Shopify Storefront API
Section titled “Reading from the Shopify Storefront API”For headless storefronts, query the metafield field on a product through the GraphQL Storefront API:
query ProductSwatches($handle: String!) { product(handle: $handle) { id title swatchGroups: metafield(namespace: "pl_swatches", key: "groups") { value } }}The value is a JSON string. Parse it client-side to get the same payload you’d see in Liquid.
Reading from another app
Section titled “Reading from another app”Any Shopify app with the read_products access scope can read pl_swatches.groups like any other custom metafield. No special integration is needed.