Skip Navigation

[Resolved] Custom filter stop working

This support ticket is created 3 years, 3 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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: Asia/Kolkata (GMT+05:30)

This topic contains 8 replies, has 3 voices.

Last updated by dream-cityC 3 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2269735

Tell us what you are trying to do?
We use to have this filter working perfectly but suddenly it stops working and we don't know why

Is there any documentation that you are following?
https://toolset.com/forums/topic/i-need-to-make-a-dropdown-filter/

Is there a similar example that we can see?

What is the link to your site?
hidden link

#2270245

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi there

You are referring to the price dropdown on the page you linked to, correct?

I can see that it is not working, though it is not clear why from the front end alone.

The first step would be to rule out any conflicts with any 3rd-party code that could be breaking the filtering feature (a plugin update could explain why this stopped working, for example).

Ideally on a staging or development server, could you disable all non-Toolset plugins and test the page again? If it still doesn't work, try switching theme to twentytwentyone.

If the search filter does start working then it should be possible to identify where the conflict comes from by re-activating your plugins one at a time, or in batches, and re-testing.

Let us know what you find so we can see how to proceed.

#2270247

Minesh
Supporter

Languages: English (English )

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

Can you please follow the steps suggested by Nigel and get back to us.

#2270623

sorry for the late response
the problem is still there, I've disabled everything

#2271239

Minesh
Supporter

Languages: English (English )

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

Strange. This needs to be debugged further.

Can you please share admin access details and tell me what view you are using.

*** 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.

#2271993

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

It seems somehow your view settings was changed.

I've set the correct "Custom Search" settings for your view as you can see with the following screenshot:
- hidden link

Can you please confirm it works as expected now.

#2275167
Screenshot 2022-01-25 100959.png

sorry for the late response, we were off in the office these days
Nothing has change the prince range does not work

#2277531

Minesh
Supporter

Languages: English (English )

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

The thing was that the view ID was not added to view's filter as well as view IDs added wrong way.

I've corrected and adjusted the view's filter as given under:

add_filter('wpv_filter_query', 'func_search_price_range_views_woo_price', 90, 2);
function func_search_price_range_views_woo_price($query, $setting) {
  
    $view_ids = array(32269,32271,32273,71708,74357,76120);
    if (in_array($setting['view_id'],$view_ids) ) {
     
        
      if(defined( 'DOING_AJAX') and DOING_AJAX ) {
         
        foreach($_POST['search']['dps_general'] as $k=>$v):
            if($v['name']=='wpv-views_woo_price'){
               $price = explode("-",$v['value']);
               $query['wpv_min_price'] = $price[0];
      			$query['wpv_max_price']  =  $price[1];
                    
            }
        endforeach;
      } 
         
      if(isset($query['meta_query']) and !empty($query['meta_query'])) {  
      
        foreach((array)$query['meta_query'] as $k=>$v):
      
          if(isset($v['key']) and ($v['key']=='views_woo_price' or $v['key']=='wpv-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;
      }else{
      		if(isset($_GET['wpv-views_woo_price'])){
              		 $price = explode("-",$_GET['wpv-views_woo_price']);
                   
              		 $query['wpv_min_price'] = $price[0];
      				$query['wpv_max_price']  =  $price[1];
            }
      }
      
   }
    return $query;
}

Can you please confirm it works as expected: hidden link

#2277945

Perfect, now is working fine, I don't know how it messed up like that but thanks
My issue is resolved now. Thank you!