Quantcast
Channel: Opinion: Shopify Community - Shopify & Ecommerce Jobs
Viewing all articles
Browse latest Browse all 7259

Filtering with Metafield data (Developer) by Christopher Nguyen

$
0
0

Hello,

I am looking for a developer or a firm that can implement a simple sorting filter that returns products within a certain range. I have metafields on my products, and each of them have a metafield with an integer value. I want to sort by this integer value.

"Purity" is stored as an integer value. For example:

PRODUCT A
Purity: 78 (integer)

PRODUCT B
Purity: 90 (integer)

The user could have two boxes or a slider that puts a bottom or max value for purity. For example: USER INPUT: 85 to 95.

The filter returns PRODUCT B, since its purity is 90 (it is within the range 85 to 95).

____________________

Notes for other developers:

I know that this kind of filtering functionality exists; it's just whether I can pass values from the front to the back. I edited collections.liquid to access this metafield data and only return those products meeting the criteria. In brief, it is a for loop through the products, and one conditional with the parameters: e.g., for products in collection, if product.metafields.namespace.purity >= 85 and <= 95, print item.

However, I am only able to hardcode in the values 85 to 95. What I need is for a user to be able to input these values. What I need is to be able to pass the values/variables from a form (the user's slider or two input boxes) into my liquid code, e.g., in place of 85 and 95. (Is this possible? If not, is there a workaround?)

Thank you, and please contact me as soon as you can.


Viewing all articles
Browse latest Browse all 7259

Trending Articles