Skip Navigation

[Resolved] Range between two fields in Custom Search

This support ticket is created 5 years, 11 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 13 replies, has 2 voices.

Last updated by Minesh 5 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#1210520

Hi,

I have a Custom Search hidden link with fields (Min and Max), which I can´t make working as I would like to. The posts that should be displayed have custom fields which are used for possible investment (min and max range). Later I want make it as a slider.

For example CPT has Min value set to 1000 and Max value to 5000. If user place min i.e. 1500 and max 4500, it is ok. But if the user set Max to 5500, no post will be displayed even the post would suite the user, because his minimal is 1500 and company minimal is 1000.

Min [wpv-control-postmeta field="wpcf-minimalni-vklad" type="textfield" url_param="vklad_min" output="legacy"]
Max [wpv-control-postmeta field="wpcf-maximalni-vklad" type="textfield" url_param="vklad_max" output="legacy"]

Query filter is set as:
Field Min as a Number - lower than or equal - URL parameter vklad_min
Field Max as a Number - greater than or equal - URL parameter vklad_max

#1210599

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - what if you try to change your filter to use the "BETWEEN" clause.

Please check the following screenshot:
=> hidden link

For example - you can see how the range filters configureed using the following test site on our test platform discover-wp.com.
=> hidden link

You can create test site for you from here and learn how price range filter is working:
=> http://discover-wp.com/register/?site_type=713

Regarding, integrating the min-max value as the slider, thats a custom work which is beyond the scope of our support policy. You can try to assign the slider value to the needed query argument value.

#1210772

Hi Minesh,

I have tried BETWEEN as a first option, but does not work me. I have also tried changing number to UNSIGNED.

Maybe I didn´t explain it well.

CPT
Field "minimalni-vklad" 1000 - min value, which user can invest
Field "maximalni-vklad" 5000 - max value, which user can invest

Custom Search
Min [wpv-control-postmeta field="wpcf-minimalni-vklad" url_param="vklad_min" output="legacy"]
Max [wpv-control-postmeta field="wpcf-maximalni-vklad" url_param="vklad_max" output="legacy"]

I.e. user can invest his min 1500 and max 4500, so the CPT should be displayed, but it is not happening in my case. The user also should see the CPT if he set min to 500, because he is still in the range of his possibilities to 4500 (under company max 5000).

#1211239

Minesh
Supporter

Languages: English (English )

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

Can you please share access details so I can check why the filters you added is not working.

*** 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

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

#1211415

Minesh
Supporter

Languages: English (English )

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

Ok - I've fixed the issue for the filtering for min and max values.

=> hidden link

I've change the view's filter to:

AND
Minimální vklad is a number lower than or equal URL_PARAM(vklad_min)
AND
Maximální vklad is a number greater than or equal URL_PARAM(vklad_max)

I will check your other ticket tomorrow.

#1211699

Minesh
Supporter

Languages: English (English )

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

Can you confirm that this filter issue is resolved?

#1212017
filters.png

Hi Minesh,

the actual view fielter as you have set now is the same as I had before (https://toolset.com/forums/topic/range-between-two-fields-in-custom-search/#post-1210520), so unfortunately its not working as I would like to. I have created a pic that demonstrates how it should work.

#1212529

Minesh
Supporter

Languages: English (English )

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

Well - I would like to know here the reason why it should not display the post for the range 500 to 700?

#1212676

Because the company offers minimal investment from 1000, and the user´s maximal investment is 700 only.

#1213033

Minesh
Supporter

Languages: English (English )

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

Well - have you define minimum and maximum investment values or we can consider the static value?

#1213084

Each post has own minimum and maximum investment value. These fields are: "minimalni-vklad" and "maximalni-vklad", both defined as numbers.

#1213157

Minesh
Supporter

Languages: English (English )

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

Well - I wonder why the search is displaying another post type post when I search for min value 500 and max value 700.
=> hidden link

Have you added any other related code related to this view? if so, can you disable that for now, please?

In addition to that, I see you have 4 posts available:
=> hidden link

And one post minimum value is set to 0. And the example you shared is with different values. I will try to correct the last two cases.

#1213594
filters-update.png

Hi Minesh,

there was one related code to this View, so I have removed it.

For testing purposes I have added some fields into template for the View, so you can see the "Min vklad" (= minimal possible investment) and "Max vklad" (=maximal possible investment) fields. Also for test purposes I have added range 1000-5000 like on the image to this post "Test product": hidden link.

I have updated the image, so in right column you can see what is working or not.

#1213764

Minesh
Supporter

Languages: English (English )

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

Well - I still do not understand the logic behind the post displayed and post not displayed.

We have contradiction here either you can cehck:
Type 1 - min value =< 1000 and max value >= 6000
OR
Type 2 - min value >= 1000 and max value <= 6000

We can not cover both case which is in your screenshot.

We are currently applying the "Type 1" - so respectively, Let's talk about not working cases:
1st case => Min value 500 and Max value 6000
(Test product value min:1000 max:5000)
=> This product is not displayed because min value is fine but max value input is 6000 but test product max value set to 5000

So, you need to be clear either we can set condition "Type 1" or "Type 2"