Skip to content
Advertisement

Array filter JSON data with price parameter

I have this JSON data and I am using this code to match the title. It works, but now I want to go one step further and list all products which are less than some price, or more than some price, or equal to some price

JavaScript

This works flawlessly for title but we want to filter based on variant price. There may be several prices for one variant and if $filter_value is greater than, equal to, or less than, anyone can occur.

For example user may search for product whose minimum price is 50, so in that case, if any variant is matching criteria then it will list those products, or user may search that all variants’ prices should be less than 50.

We tried like this

JavaScript

but it did not work. We tried foreach and tested again but it always gave empty result

Advertisement

Answer

Here is possible solution

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement