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 has 1 reply, 2 voices, and was last updated 5 years, 10 months ago by
Ernest Marcinko.
-
AuthorPosts
-
July 15, 2020 at 11:54 am #28484
patriziord
ParticipantHi 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 MATCHWhat 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 overlappingIs 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
July 15, 2020 at 1:39 pm #28491Ernest Marcinko
KeymasterHi 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. -
AuthorPosts
- You must be logged in to reply to this topic.