Make search by two date fields [from] … [to] results match when overlapping

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Make search by two date fields [from] … [to] results match when overlapping

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 3 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #28484
    patriziord
    patriziord
    Participant

    Hi Ernest,

    having a travel agency website with the following criteria:
    each travel offer has two custom fields (acf date picker), ‘from’ and ‘to’;
    administrator sets a period of time during which the offer is available – i.e. from 20 July to 15 August;

    having a ASP search fieldset, like the followin:
    [text search field] – [date ‘from’] – [date ‘to’]

    at this very moment, search results match only the offers whose from-to dates are within the dates the user sets.
    For example:
    user sets “calabria” – from: 30 July to: 31 August
    offer “Pizzo Calabro” having fields from: 2 August to: 29 August – DOES MATCH and show in results
    offer “San Teodoro” from: 1 Sept to: 16 Sept – DOES NOT MATCH
    offer “Happy Holiday” from: 28 July to: 15 August – DOES NOT MATCH
    offer “Villaggio Calabro” from: 18 August to: 6 Sept – DOES NOT MATCH

    What I’m trying to do:
    I would let the results showing any offer whose time period from-to just overlaps the period the user sets.
    Using the example above, I would like to have results behaviour like the following:

    user sets “calabria” – from: 30 July to: 31 August
    offer “Pizzo Calabro” having fields from: 2 August to: 29 August – DOES MATCH and show in results
    offer “San Teodoro” from: 1 Sept to: 16 Sept – DOES NOT MATCH
    offer “Happy Holiday” from: 28 July to: 15 August – DOES MATCH and show in results – it’s overlapping
    offer “Villaggio Calabro” from: 18 August to: 6 Sept – DOES MATCH and show in results – it’s overlapping

    Is this feasible with just some configuration?
    I tried using “show results before / after the date inclusive“, but doesn’t look the right way?
    Is there an other way via code, modifing the query filtering maybe? In this case, also a tip in the right direction, would be much appreciated.

    Thanks in advance.

    Patrizio

    #28491
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Patrizio,

    Well, you can try to change the logic between the custom field filters matching here. That will sort of do the trick.
    This would be far more complicated via custom code, I’m not sure if I can recommend anything.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


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

You must be logged in to reply to this topic.