Forums Forums Search & Filter Pro Filter that searches in one field or between two fields

Viewing 10 posts - 1 through 10 (of 11 total)
  • Anonymous
    #253539

    Scenario:
    – A product has two custom fields (PH and PH_MAX).
    – PH is always filled in
    – PH_MAX is only filled in if the PH is not exact and it can vary in between values PH and PH_MAX

    Search requirements;
    – When a visitor searches for PH = 7 it should find any products that ( PH = 7 OR ( PH_MAX != ” and PH <= 7 AND PH_MAX >= 7 ) )

    Is this possible, even if it’s by using hooks with our custom code?

    Ross Moderator
    #253545

    Hi Diogo

    The only way I can think of is this setup:

    1) You always fill in PH_MAX (even when not needed)
    2) You create a Post Meta -> Number Range field, with different start / stop meta keys (using PH and PH_MAX)
    3) You use JavaScript on the front end, to show / hide / set the “Max” field according to what the user has pressed – it could be permanently hidden, and you would manipulate the field according to what you need

    Thanks

    Anonymous
    #253576

    I understand 1) and 2) and it does make sense.

    Why 3) ?

    Ross Moderator
    #253583

    3) Well, it wasn’t a fully fleshed implementation, but I thought you might need to change this depending on the value you put in for posts that don’t need a max, but you fill it anyway. However, if you set the max field for these posts that wouldn’t use the field normally, to the max value, you might not need to do this step. I’m assuming you want to show one field only not both min/max.

    Best

    Anonymous
    #253596

    OK, got it. Will try that.

    Anonymous
    #261610

    This was not a very elegant solution.

    1) Currently, with the post meta “number” type of field, we can create a range filter that allows us to search a specific range of user-selected values in a range defined by two post meta fields.

    Example: https://snipboard.io/1rIUR8.jpg
    Results in: https://snipboard.io/S6aCh8.jpg

    This will show me all the posts that have a value between the range of x and y on the field _ph_key to _ph_key_max range.

    For example, if I search 4 to 5 it will return all posts that have ( _ph_key >= 4 and _ph_key <= 5 ) OR ( _ph_key_max >= 4 and _ph_key_max <= 5 ).
    In sum: all posts which range overlaps.

    2) With the post meta “choice” type of field, we can only search in one specific meta key.

    Example: https://snipboard.io/Myoia7.jpg
    Results in: https://snipboard.io/2FkOCU.jpg

    But this will only search on _ph_key. Not what we need.

    3) We need something that is a mix of these situations. We need a single “choice” field populated with all options existing in both _ph_key and _ph_key_max meta fields and search between them.

    Example: If I chose “5”, we need it to return all posts that have _ph_key>=5 and _ph_key_max<=5

    Is this even possible with this plugin at the moment?
    If this is not an option at the moment, how much would it cost for us to sponsorship this new feature and make it available for everyone?

    Ross Moderator
    #262132

    Hi Diogo

    Just to let you know I’ve not forgotten about this – will pick it up tomorrow.

    Thanks

    Anonymous
    #262161

    We solved it already by filling both regular and max fields.

    Nevermind this. Please look at our other tickets, mainly the one regarding pagination.

    Ross Moderator
    #262207

    Great stuff.

    Ross Moderator
    #262209

    BTW, your field “Subtract” has many many options, I think this will slow down the speed.

    Thanks

Viewing 10 posts - 1 through 10 (of 11 total)