• Resolved zul114

    (@zul114)


    Is it possible to add a search input on the main page that links to the store locator. It would be a simple zipcode search

    For example, enter zipcode to search for store: Input here —> takes you to the store locator page with the zipcode already in?

    https://ww.wp.xz.cn/plugins/wp-store-locator/

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

    (@tijmensmit)

    You would have to modify the code for it to work. There are some threads about this on the forum with code examples, but I can’t find them back at the moment. Maybe if you go back through old post you can find it?

    Hey Tijmen,

    I looked those those other threads and this one brought me most of the way, but my big question is what is the URL that allows to query a zip code?

    http://mydomain.com/locations/?zip=60654 is what is currently passing now. http://mydomain.com/locations/ is where I have included the [wpsl] shortcode.

    What am I missing to get this up and running?

    Thank you kindly.

    Plugin Author Tijmen Smit

    (@tijmensmit)

    You have to grab the url parameter with JS, set the zip code in the search field with jQuery and trigger the submit button.

    Plugin Author Tijmen Smit

    (@tijmensmit)

    So you need to add code the /js/wpsl-gmap.js that first checks if the zip param exist, if so grab it, set it in the search field and trigger a submit.

    Totally makes sense, I have done all of that and it creates a url http://mydomain.com/locations/?zip=60654

    Which does nothing but go to the locations page (no zip is actually queried)…

    So my only question is: what needs to be done so a URL can actually query a zip? What does that URL look like?

    Plugin Author Tijmen Smit

    (@tijmensmit)

    Which does nothing but go to the locations page (no zip is actually queried)…

    So my only question is: what needs to be done so a URL can actually query a zip? What does that URL look like?

    Yes, that’s why you need to do this:

    So you need to add code the /js/wpsl-gmap.js that first checks if the zip param exist, if so grab it, set it in the search field and trigger a submit.

    If you open the /js/wpsl-gmap.js file, and search for ‘$( “#wpsl-search-btn” ).on( “click”, function( e )’, you see it calls ‘codeAddress()’, that functions grabs the value from the search field , geocodes it, calls the ‘findStoreLocations’ function and in the end you should see the store results.

    All you have to is add code that checks for the zip param, and if that exist set the value in the search field and trigger the submit button.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Search bar’ is closed to new replies.