• Resolved artkom

    (@artkom)


    Hello everyone.

    I now that this problem was encountered in many topics before, but I am steel don’t find solution. I place this in default.js of my theme:

    // zip code search (home page)
    jQuery(function ( $ ){
    	$('#wpsl-search-button-home').click(function() {
    		var url = '/pages/location-search/?zip=';
    		var inputURL = $('#wpsl-search-input-home').val();
    		window.location.href = url + inputURL;
    		return false;
    	});
    });
    
    // get parameter and post on location search
    jQuery(function ( $ ){
    	$.urlParam = function(name){
    		var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    		if (results==null) {
    			return null;
    		} else {
    			return results[1] || 0;
    		}
    	}
    
    	if ($.urlParam('zip')) {
    		// set the default value of a text input field
    		$('#wpsl-search-input').val(decodeURIComponent($.urlParam('zip')));
    
    		// delay and click button
    		setTimeout(function(){
    			$('#wpsl-search-btn').click();
    		},5000);  // In my case 5000 because I have many stores
    	}
    });

    But I still don’t know what should be on index page (it would be the html code of input and submit button for redirect to the store locator page with search results)? The code like this is not working:

    <div>
     <div class="wpsl-input"><input id="wpsl-search-input1" autocomplete="on" type="text" value=""></div>
     <div><a>Locate</a></div>
    </div>

    Please help me to find a solution of these problem.
    Thanks in advance

    P.S.Sorry for my English

    https://wordpress.org/plugins/wp-store-locator/

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

    (@tijmensmit)

    I don’t have time for this at the moment, but I will get back to you soon and go through your code.

    Thread Starter artkom

    (@artkom)

    @tijmen Smit Thank you so much. I`m slowpoke )

    I`m finally find a solution!. Its a really simply.
    Here the code for index page with input form for store localor:
    <input autocomplete="off" id="wpsl-search-input-home" type="text" value="test" name="wpsl-search-input"><input id="wpsl-search-button-home" type="submit" value="Search">

    @artkom what is the function of your code? when the user select address/store in store locator form the result will go to another page?

    Thanks for this! It was exactly what I was wanting to accomplish. But, after my location (map) page loads with the correct results, I get an alert stating ‘No results found.’ Is anyone else having this problem or has anyone solved it?

    Thread Starter artkom

    (@artkom)

    @tenkepadu Yes. You can place search form for store locator on any page. When visitor is searching store in this form the system redirecting visitor on locator`s page with results.

    Thread Starter artkom

    (@artkom)

    @bobquznie No. I dont have this problem. Maybe you have double this form in store locators page (if you place search form in header, and main form on page)? Then try delete added form on store locator`s page. Or fix this like set display:none for added form

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

The topic ‘Locator Search from another page’ is closed to new replies.