Well, medium range(15-25) looks pretty good.
In 'small' range lower than 10 are missing and 'large' result is 'No items found'.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
I checked all the range now and I can see its working.
Here is the modified code added to functions.php file:
add_action('pre_get_posts', 'registration_date_and_today',999,1);
function registration_date_and_today($query){
if(is_archive('product') and isset($_REQUEST['search']['dps_general'])){
foreach($_REQUEST['search']['dps_general'] as $k=>$v):
if($v['name'] == 'wpv-wpcf-total-area[]'){
$range = explode("-",$v['value']);
$meta_query[] = array(
'relation'=>'AND',
array(
'key' => 'wpcf-total-area',
'value' => $range[0],
'type' => 'NUMERIC',
'compare' => '>=',
),
array(
'key' => 'wpcf-total-area',
'value' => $range[1],
'type' => 'NUMERIC',
'compare' => '<=',
)
);
$query->set('meta_query',$meta_query);
}
endforeach;
}
}
Can you please confirm it works as expected: hidden link
Minesh, You really did good job. Just couple more things.
Ranges do not work simultaneously, so I changed checkboxes to radios, as they makes more sense for user also in current case. Result was not good. Is there something, I should do after type change?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
I see on the site you still have checkboxes filter available. I already show you how you can customize the query as it will require more or less custom programming which is beyond the scope of our support policy.
However - I would still really want to help you out but you need to be precise with your requirement. Do you want me to setup a radio button filter instead of checkboxes?
Yes, Minesh.
Help me one more time to setup a radio button filter instead of checkboxes.
After setting type to 'radios' filter displays only products with the the first value of range.
Thanks again!
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Can you please check now. I've adjusted the if condition within the pre_get_posts hook as given under:
if($v['name'] == 'wpv-wpcf-total-area'){
Can you please confirm it works as expected using radio button as well.
=> hidden link
Very nice!
I do confirm, filter ranges works as expected using radio buttons.
Before closing this ticket:
Is there a way to choose "show all values for inputs" by type?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
No - there is no such option. "show all values for inputs" will be applied as globally to all the filters.
My issue is resolved now. Thank you!