How to create Custom Filter via Shopify Metafields
Creating Custom Filter via Shopify Metafields
Sam as to the product variant, you can create custom filters by creating meta fields either for product or variant. While adding a meta field for custom filter use, you need to make sure the content type should be one of the following:
- Single-Line Text
- Integer or Decimal Number
Follow these steps to create a meta field definition:
- Go to Settings > Metafields from your Shopify store admin.
- Select the type of metafield you want to create. Let’s say, Products.
- Click the Add definition button.
- In the Name field, enter a name for your definition, such as “Age Group”.
- Next, enter a description for your metafield values (optional).
- Click Select content type, and then select the content type (Text or Number).
- If the Content type is Text, select “Single line text”. And for Number content type, select either Integer or Decimal.
- In the Validation section, configure the Additional rules to limit the range of accepted values (optional).
- Save the changes.
After creating a meta field definition, you need to add values to this meta field. Follow the steps to add values to the product meta field definition:
- Go to Products > All products from your Shopify store admin.
- Click on any product.
- Scroll down to the metafields section, enter the value for the recently created metafield, i.e. Age Group.
- Save the changes.
You’ve successfully created a custom filter by creating a meta field. Now, you can check whether your recently created meta field is present in the filter options or not. Also, you can add it to show on your collection page by following the below steps:
- Go to Online Store > Navigation from Shopify store admin.
- Click on Add filters.
- In Metafields options, select the recently created metafield, i.e. “Age Group”.
- Click Done.
Show your filter in fronted
Let me know if this solves your problem or if you need further help!