Skip Navigation

[Resolved] I need to make a dropdown filter

This support ticket is created 4 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 12 replies, has 3 voices.

Last updated by dream-cityC 4 years, 8 months ago.

Assisted by: Jamal.

Author
Posts
#1729675
Untitled.png

Tell us what you are trying to do?
I am trying to: get a real estate type price filter to work and
I want to make a a dropdown filter with just one field(price)

Is there any documentation that you are following?

Is there a similar example that we can see?
like this one US$ 100,000 - 299,999
like this webpage
hidden link

What is the link to your site?
hidden link

#1730633

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to know are you using Blocks or view to build your custom search.

When you try to add a price filter, it will allow you the option to add a custom price values so you can setup the custom price range as option as you displayed with your screenshot.

If you can share problem URL Where you want to implement the such price range and share price range you want to add with access details I would be happy to set it up for you.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1731239

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please send me the price range values you want to display with price filter - so that I will add the filter hook code accordingly.

#1731249

Perfect thanks, when you finish that would like to explain me how to do it?
It will be the same as the picture

All= all the property
0 - US$ 99,999 = the property between 0 and 99,999
US$ 100,000 - US$ 299,999 = the property between 100,000 and 299,999
US$ 300,000 - US$ 499,999 = the property between 300,000 and 499,999
Above US$ 5000,000 = every property above this price

#1731299

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've setup the filter values to "Search and Pagination" section as given under:

[wpv-control-postmeta type="select" field="views_woo_price" source="custom" url_param="wpv-views_woo_price" values=",0-99999,10000-299999,300000-499999,>=500000" display_values="All,US$ 0.00 - US$ 99%%COMMA%%999,US$ 100%%COMMA%%000 - US$ 299%%COMMA%%999,US$ 300%%COMMA%%000 - US$ 499%%COMMA%%999,Above US$ 500%%COMMA%%000"]

I've added the following code to "Custom Code" section offered by Toolset:
=> hidden link

add_filter('wpv_filter_query', 'func_search_price_range_views_woo_price', 90, 2);
function func_search_price_range_views_woo_price($query, $setting) {
    if($setting['view_id'] == 16269) {
         
        foreach((array)$query['meta_query'] as $k=>$v):
            if(isset($v['key']) and $v['key']=='views_woo_price'){
                         
                  
                      $query['meta_query'][$k]['key'] = 'views_woo_price';
                      $query['meta_query'][$k]['type'] = 'NUMERIC';
              		 if($v['value']=='>=500000'){
                       $query['meta_query'][$k]['compare'] = '>=';
                       $query['meta_query'][$k]['value'] = str_replace(">=","",$v['value']);
                     }else{
                        $query['meta_query'][$k]['compare'] = 'between';
                        $query['meta_query'][$k]['value'] = str_replace("-",",",$v['value']);
                     }
                
            }
        endforeach;
    }
    return $query;
}

Can you please check now and test if its working as expected: hidden link

#1731307

Thank you so much
I added one 0 to this "10000-299999"

I didn't imagine it that it was like that
could never do that

Thanks

#1731311

My issue is resolved now. Thank you!

#1731313

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to know that solution I shared help you to resolve your issue 🙂

#1731319

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It seems we cross-posted it - feel free to mark it resolved with by changing the default resolved message.

#1731363

My issue is resolved now. Thank you

#1731409

Sorry to bother again but i noticed something , is about the order of the properties. They don´t have an specific order, is there a way to order them from min to max price as default when the filter is applied ?

Actually is it possible to add a option that the user can sort the prices from min to max / max to min but that the default is min to max.

#1734233

Hello. Minesh is on vacation, so, If you don't mind, I'll continue with you on this ticket.

You can, currently, sort the view by price, from min to max or max to min, check this screenshot hidden link

But, your default sorting control is set on the post title, as you can see on this screenshot hidden link

If you need the view to be sorted by price, min to max, by default, you will need to edit your sorting control and reconfigure it to use the price first.

I hope this answers your question. Let me know if you have any doubts.

#1735989

My issue is resolved now. Thanks
It was easy with your solution