Search FROM DATE including the date

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search FROM DATE including the date

This topic contains 9 replies, has 2 voices, and was last updated by Miguel Miguel 4 years, 11 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #22311
    Miguel
    Miguel
    Participant

    Hello, I am having a problem with the search combined with The Events Calendar.

    I have a search widget that you can find on the right column of my website and there are two date pickers, to select DATE FROM and TO DATE.

    The problem is that it does not include the FROM date, EXAMPLE:

    If I search events FROM May 1st, the first result is for May 2nd, not including the events on May 1st, which is something that I need to happen.

    Could we solve this, please?

    Thanks and regards,
    Miguel.

    #22315
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Miguel,

    This is currently only possible by making direct changes to the main plugin files. If you want to change that, then please follow these instructions:

    1. Make sure to have a site back-up first, just in case.
    2. Open up the wp-content/plugins/ajax-search-pro/includes/classes/search/class-asp-search-cpt.php file, and find these lines (around 980-1020):

                    // Is this a special case of date operator?
                    if (strpos($operator, "datetime") === 0) {
                        switch ($operator) {
                            case 'datetime =':
                                $current_part = "($wpdb->postmeta.meta_value BETWEEN '$posted 00:00:00' AND '$posted 23:59:59')";
                                break;
                            case 'datetime <>':
                                $current_part = "($wpdb->postmeta.meta_value NOT BETWEEN '$posted 00:00:00' AND '$posted 23:59:59')";
                                break;
                            case 'datetime <':
                                $current_part = "($wpdb->postmeta.meta_value < '$posted 00:00:00')";
                                break;
                            case 'datetime >':
                                $current_part = "($wpdb->postmeta.meta_value > '$posted 23:59:59')";
                                break;
                            default:
                                $current_part = "($wpdb->postmeta.meta_value < '$posted 00:00:00')";
                                break;
                        }
                        // Is this a special case of timestamp?
                    } else if (strpos($operator, "timestamp") === 0) {
                        switch ($operator) {
                            case 'timestamp =':
                                $current_part = "($wpdb->postmeta.meta_value BETWEEN $posted AND ".($posted + 86399).")";
                                break;
                            case 'timestamp <>':
                                $current_part = "($wpdb->postmeta.meta_value NOT BETWEEN $posted AND ".($posted + 86399).")";
                                break;
                            case 'timestamp <':
                                $current_part = "($wpdb->postmeta.meta_value < $posted)";
                                break;
                            case 'timestamp >':
                                $current_part = "($wpdb->postmeta.meta_value > ".($posted + 86399).")";
                                break;
                            default:
                                $current_part = "($wpdb->postmeta.meta_value < $posted)";
                                break;
                        }
                        // Check BETWEEN first -> range slider
                    } else if ( $operator === "BETWEEN" ) {

    3. Change that to this:

                    // Is this a special case of date operator?
                    if (strpos($operator, "datetime") === 0) {
                        switch ($operator) {
                            case 'datetime =':
                                $current_part = "($wpdb->postmeta.meta_value BETWEEN '$posted 00:00:00' AND '$posted 23:59:59')";
                                break;
                            case 'datetime <>':
                                $current_part = "($wpdb->postmeta.meta_value NOT BETWEEN '$posted 00:00:00' AND '$posted 23:59:59')";
                                break;
                            case 'datetime <':
                                $current_part = "($wpdb->postmeta.meta_value < '$posted 23:59:59')";
                                break;
                            case 'datetime >':
                                $current_part = "($wpdb->postmeta.meta_value > '$posted 00:00:00')";
                                break;
                            default:
                                $current_part = "($wpdb->postmeta.meta_value < '$posted 23:59:59')";
                                break;
                        }
                        // Is this a special case of timestamp?
                    } else if (strpos($operator, "timestamp") === 0) {
                        switch ($operator) {
                            case 'timestamp =':
                                $current_part = "($wpdb->postmeta.meta_value BETWEEN $posted AND ".($posted + 86399).")";
                                break;
                            case 'timestamp <>':
                                $current_part = "($wpdb->postmeta.meta_value NOT BETWEEN $posted AND ".($posted + 86399).")";
                                break;
                            case 'timestamp <':
                                $current_part = "($wpdb->postmeta.meta_value < ".($posted + 86399).")";
                                break;
                            case 'timestamp >':
                                $current_part = "($wpdb->postmeta.meta_value > ".($posted).")";
                                break;
                            default:
                                $current_part = "($wpdb->postmeta.meta_value < $posted)";
                                break;
                        }
                        // Check BETWEEN first -> range slider
                    } else if ( $operator === "BETWEEN" ) {

    4. Save the file, and that should do the trick.

    Best,
    Ernest Marcinko

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


    #22318
    Miguel
    Miguel
    Participant

    Ok thanks.

    WIll the changes be lost upon updates? Maybe you could make this as default, usually it works like this, right. If I choose FROM date I expect it to be included.

    Thanks!!

    #22319
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I will include an option to in the upcoming release to have an inclusive version on the custom field selectors panel, that will resolve the problem.

    Best,
    Ernest Marcinko

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


    #22320
    Miguel
    Miguel
    Participant

    That would be awesome.

    By the way, I finally started the website last monday after some months of development and it’s being a great success.

    Your plugin is a very important part of this project, so congratulations for your great work and thanks for the attention.

    Thanks!!

    #22324
    Miguel
    Miguel
    Participant

    Here I am again, I tried the code and it seems to work only on one instance of the plugin.

    If you see the widget on the right column in infoTandas.com, you can see there are two tabs, each of them with one instance of Ajax Search Pro.

    Well, after updating your code, the CARS instance works perfect, showing events the same day of the DATE FROM selected field. But in MOTORCYCLE tab, does not work.

    Why can this be?

    Thanks!

    #22326
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I think this might be related to exact dates without times, maybe try this variation:

                    // Is this a special case of date operator?
                    if (strpos($operator, "datetime") === 0) {
                        switch ($operator) {
                            case 'datetime =':
                                $current_part = "($wpdb->postmeta.meta_value BETWEEN '$posted 00:00:00' AND '$posted 23:59:59')";
                                break;
                            case 'datetime <>':
                                $current_part = "($wpdb->postmeta.meta_value NOT BETWEEN '$posted 00:00:00' AND '$posted 23:59:59')";
                                break;
                            case 'datetime <':
                                $current_part = "($wpdb->postmeta.meta_value <= '$posted 23:59:59')";
                                break;
                            case 'datetime >':
                                $current_part = "($wpdb->postmeta.meta_value >= '$posted 00:00:00')";
                                break;
                            default:
                                $current_part = "($wpdb->postmeta.meta_value < '$posted 23:59:59')";
                                break;
                        }
                        // Is this a special case of timestamp?
                    } else if (strpos($operator, "timestamp") === 0) {
                        switch ($operator) {
                            case 'timestamp =':
                                $current_part = "($wpdb->postmeta.meta_value BETWEEN $posted AND ".($posted + 86399).")";
                                break;
                            case 'timestamp <>':
                                $current_part = "($wpdb->postmeta.meta_value NOT BETWEEN $posted AND ".($posted + 86399).")";
                                break;
                            case 'timestamp <':
                                $current_part = "($wpdb->postmeta.meta_value <= ".($posted + 86399).")";
                                break;
                            case 'timestamp >':
                                $current_part = "($wpdb->postmeta.meta_value >= ".($posted).")";
                                break;
                            default:
                                $current_part = "($wpdb->postmeta.meta_value < $posted)";
                                break;
                        }
                        // Check BETWEEN first -> range slider
                    } else if ( $operator === "BETWEEN" ) {
    Best,
    Ernest Marcinko

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


    #22413
    Miguel
    Miguel
    Participant

    Hi!! I have received an update notification from Codecanyon, but the file I get from the downloads section has the exact same name as the one I previously had: “codecanyon-3357410-ajax-search-pro-for-wordpress-live-search-plugin” Is this updated?

    What do I need to do for a correct upgrade so I don’t loose all custom CSS? Also I changed the code you sent me in this thread but I see you included the “include date” function and I think is great. Thanks for the great work.

    P.S. I was sure I had posted back to thank you for your last code, which works great, but I didint. Sorry, thanks.

    • This reply was modified 4 years, 11 months ago by Miguel Miguel.
    #22424
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Yes, it is updated, they always name the files the same filename.
    The new, inclusion based option can be found here: https://i.imgur.com/1r5XFSt.png
    The plugin database data (configuration etc..) is not changed during updates. You can follow any of these update guides.

    Best,
    Ernest Marcinko

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


    #22476
    Miguel
    Miguel
    Participant

    Done! Thanks for adding this great functionality 😀

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

You must be logged in to reply to this topic.