Forums Forums Search & Filter Pro Making calc prior search button hit

Viewing 8 posts - 1 through 8 (of 8 total)
  • Anonymous
    #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

    Trevor
    #125114

    It would need to be done at post creation, using an ACF calculated field, and search on that.

    Anonymous
    #125212

    I don’t understand what you mean ‘at post creation’. And I don’t know if any ACF calculated field. I just use height and width in the search, so from the search I have to give the ‘surface’ with it. Can that be done in the hook?

    Trevor
    #125265

    In the posts, do you have an ‘area’ field it can search? What is the calculated number going to be compared to?

    In the posts, you maybe have these fields?

    Height
    Width
    Area

    I think you should.

    Anonymous
    #125267

    Yes, 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
    #125279

    Hi 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:

    Edit Query Arguments filter

    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
    #125285

    Thanks 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
    #125290

    I 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/

Viewing 8 posts - 1 through 8 (of 8 total)