Forums › Forums › Search & Filter Pro › Making calc prior search button hit
Tagged: calculation, hook, search
- This topic has 7 replies, 2 voices, and was last updated 7 years, 4 months ago by Trevor.
-
Anonymous(Private) August 8, 2017 at 1:41 pm #125071
Hi,
I use two ACF fields (height and width) in a S&FPro search form. I want to make a calculation (height x width) before I hit search and want to use the result of that calculation in the search throught the field with the name ‘surface’. Is that possible with the hook sf_edit_query_args?
Can you show me an example on how to do that?
Kind Regards,
Peter
Anonymous(Private) August 9, 2017 at 12:17 pm #125267Yes, I have in the ACF a field for that, but in the form I don’t wnat people to have the need to calculatie the surface. The just fill in the height and width, but I need the calculation form the form to go with the search.
Look here for the URL: http://yourpyrobel.sencwork.nl/ramen/ (dutch website)
Thanks for looking into this….. 😉Peter
Trevor(Private) August 9, 2017 at 12:45 pm #125279Hi Peter
This is not a standard feature of the plugin, but could be done, but the height and width entered would be lost on the form submit to be replaced by the area. I suspect the solution would be unsatisfactory.
You would use this:
This would allow you to perform the calculation, remove the height and width values, and add the area. The form would need to have all three fields in, but you could use CSS to hide the area field.
The reason you would have to remove the height and width is that otherwise they would be used in the filtering as well, unless you wanted them to be.
Anonymous(Private) August 9, 2017 at 12:51 pm #125285Thanks Trevor,
I was on that page and saw the hook which could do that. Since I am not a PHP specialist I would like to get some PHP directions as a start. Woudl you be so kind to do the first steps for me? So that I can finetune the rest of it?
Thanks a lot!!
Peter
Trevor(Private) August 9, 2017 at 1:39 pm #125290I cannot claim to be much better. You would need to search the forums for what other users have posted:
https://support.searchandfilter.com/forums/search/sf_edit_query_args/
-
AuthorPosts