• Hi There @tijmensmit

    I have seen a couple posts regarding this on the forums here but none fully answer my question. I am trying to accomplish a search by store name functionality. I am very familiar with code and comfortable to make any changes..

    I have followed your suggested instructions to get on the right track by using a custom template with a custom dropdown that dictates a search by name or by location.

    My problem is with how exactly to reference the searched value/store name within the wpsl_sql and wpsl_sql_placeholder_values filters

    no matter what i do the value of the wpsl-search-input input box does not seem to get included in the ajax data ($_GET or $placeholder_values) objects.

    I have a custom dropdown created for search by name or search by location and an conditional statement to handle the two, but within the condition for “search by name” i will need to know what name they attempted to search within the wpsl-search-input input box to use in the query as a LIKE with wildcards, no?

    Please advise on what i can do to solve this, any help would be greatly appreciated. I have scanned the code within the class-frontend.php to try to gain an understanding of the order of filters and how everything calls what but i cannot seem to scope out when the value of the wpsl-search-input is even used in the first place

    maybe i need to make sure it is added to the transients from the $_GET object?

    Thank you very much, i have a client who is waiting for this functionality very impatiently

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    I see the problem ?? I had an older test version that I used to make the name search work, but I added a few lines of code to the collectAjaxData function to include the value of the input field in the AJAX data, and those changes never made it to the official version.

    There’s a wpsl-custom-dropdown and wpsl-custom-checkbox class that you can use to automatically include data from dropdowns / checkboxes in the submitted AJAX data, but there’s no support for ‘wpsl-custom-input’ at the moment.

    There’s however a workaround to make it work. If the statistics add-on is active, then the search input is returned in the AJAX data.

    To make the script think you have the statistics add-on you can use this code. Just add it to functions.php inside your active theme folder.

    
    function wpsl_custom_statistics_js_settings( $settings ) {
        
        $settings['collectStatistics'] = true;
        
        return $settings;
    }
    
    add_filter( 'wpsl_js_settings', 'wpsl_custom_statistics_js_settings' );
    

    If this still doesn’t make it work, can you then create a gist with code changes you made.

    Thread Starter Detoxboss

    (@detoxboss)

    You my friend, are a legend. That indeed does add a whole SLEW of accessible data in the ajax return ($_GET object). Seems to “blanket” fix the issue within the wspl_sql, and wpsl_sql_placeholder filter. was able to grab the searched value under the label: $_GET[‘search’]

    Magically with that filter added to the functions.php, the rest of my solution just clicked into place as it should and i had a working conditional search.

    The concern to me now is.. though the solution is “solved”, am i at any potential risk as opposed to before with security?

    is this a debug/all-in-one ajax request? (As in, only intended for debug use?)

    what about speed effects on speed? (surely grabbing massive arrays of data for multiple results is inevitably slower)

    can it be.. optimized by overriding the request data array to only include the values i need perhaps?

    regardless, ACES man. big help. A working solution is all my client cares about right now so this is now a much less urgent matter ??

    • This reply was modified 6 years, 4 months ago by Detoxboss.
    • This reply was modified 6 years, 4 months ago by Detoxboss.
    • This reply was modified 6 years, 4 months ago by Detoxboss.
    Plugin Author Tijmen Smit

    (@tijmensmit)

    All the extra data that’s included now is normally only used for the statistics add-on. It’s to keep track of the search input itself, or to be able to generate more complex CSV files in the statistics add-on ( sort searches by province / states and so ). This requires the full geocode response from the Google API, which is what the majority of the new data is.

    You can leave it out by editing the wpsl-gmap.js.

    Search for this, and just remove it.

    
    //first search.
    if ( statistics.enabled ) {
        statistics.address_components = response[0].address_components;
    }
    
    //second search.
    ajaxData.statistics = statistics.address_components;
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Accessing Searched Input Value in wpsl_sql’ is closed to new replies.