DEV Community

Shaykh Abdul Muhaiman
Shaykh Abdul Muhaiman

Posted on

How to add Material and Pack Size filters to a Shopify collection

A shopper looking for a six-pack of linen napkins needs two pieces of information: what the napkins are made of and how many come in the pack. Giving those details their own filters makes them easier to find across a collection.

Define the product metafields

In Shopify admin, go to Settings → Custom data → Products. Create Material and Pack Size as single-line text metafields if each product has one value for each field. Use consistent choices such as Cotton, Linen, and Cotton blend for Material, and 4-pack, 6-pack, and 12-pack for Pack Size.

Use a list field for Material if multiple independent values genuinely apply. For a blend, decide whether a single label like “Cotton blend” best reflects how shoppers browse your catalog. If customers choose pack size as a variant on the same product page, consider filtering by the existing product option instead.

Populate the fields and enable the filters

Assign values to a few products in the same collection. In Apps → Search & Discovery → Filters, add each metafield as a filter source and give it a clear storefront label. Open the collection in a theme that supports storefront filtering.

Shopify displays only filter values that apply to the current collection or search results. If “6-pack” is missing, first check whether a product in the collection actually has that value assigned.

Test the filters together

Test product Material Pack Size
Everyday napkins Cotton 6-pack
Dinner napkins Linen 6-pack
Cocktail napkins Linen 4-pack
  1. Select Linen and check that both linen products appear.
  2. Add 6-pack and check that only the dinner napkins remain.
  3. Clear Linen and check that both six-packs return.
  4. Repeat on mobile and make sure the selected filters are visible and easy to clear.

Shopify Help Center: Adding filters with Search & Discovery

Disclosure: This article was generated by ChatGPT from the topic of the companion LinkedIn carousel.

Top comments (0)