php - Woocommerce search product based on attributes


I have the simple products having the attributes like color: red, from year: 1988, to year:1994, etc.

I have created search form that search the product based on the parameter selected in form's drop down.

The form contain two drop down. 1-Color, 2-Year.

I have the problem with year attributes. The functionality would be like when users select the year (for example 1990) from the drop down then it should return all the products whose “From Year” value less then selected value(1990) and “To Year” value is greater than selected value(1990).

That means selected value must be between products from year and to year. Please help me to write meta query that return the products list as describe above.

'meta_query' => array( 
                  array( 'relation'=> 'AND' ), 
                  array( 'key' => '_product_attributes', 
                         'value' => red, 
                         'compare' => 'like'),

People are also looking for solutions to the problem: php - Applying multiple middlewares on routes laravel


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.