• Resolved timmy321

    (@timmy321)


    Hi there,

    I’m new to website building so please bear with me.

    I would like to link the store search options in my gym locator page ( http://findgyms.co.uk/gym-locator/ ) to the button on my homepage:

    http://findgyms.co.uk/

    I’ve done a lot of googling and still can’t figure out how to do it or what the right questions to be asking are.

    Basically I would like the user to be able to put their post code/zip code or location into the button on the homepage and that link to the store location results page. (I haven’t put any markers in yet though)

    I’ve seen this on a number of websites so I imagine it is possible, I just don’t know how.

    Could anyone please help?

    Many thanks in advance,

    Tim

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

Viewing 15 replies - 1 through 15 (of 31 total)
  • Thread Starter timmy321

    (@timmy321)

    Also, when putting any location or post code into the search function on

    http://findgyms.co.uk/gym-locator/

    the message ‘location not found’ pops up regardless of any location that I put in.

    I imagine I have done something wrong here too?

    Many thanks if anyone can help with this question too,

    Tim

    Hi @timmy321

    Thank you for getting in touch, sorry to hear you are experiencing issues.

    It looks like the Nominatim geocoder may be experiencing issues, please can we ask you to temporarily remove the Country Restriction to get started, for some reason we’re seeing an empty results set coming back regardless of which address is entered.

    Regarding having a separate form, unfortunately our plugin does not support that right now. You’d need to write your own JavaScript to read query variables and populate the store locator, we are working on this but it’s not currently supported.

    Is there anything else I can help you with?

    Kind regards
    – Perry

    Thread Starter timmy321

    (@timmy321)

    Thank you very much for the reply Perry.

    I will try the removing country restriction when I next get on the pc (on mobile currently).

    Thank you for the suggestion regarding javascript, I feel writing my own javascript may however be a bit too tricky as I don’t even know what it’s purpose or how to do it yet 🙂

    I’m also unsure whether I’ve asked the right question.. So here’s an example of what I’d like to be able to do in terms of function:

    https://www.hussle.com/

    I would like to just put the postcode into the homepage & it populate some results. Would the answer still be that I need to write my own javascript?

    If so, would you know any other options of how to achieve this?

    Many thanks Perry

    Tim

    Thread Starter timmy321

    (@timmy321)

    Ah excellent stuff, I removed the UK restriction and now it will search for the location so thank you Perry!

    I am still curious about my question above however,

    Here is another example of what I am trying to achieve:

    https://www.aldi.co.uk/store-finder

    Just in case my question does not quite make sense 🙂

    I eagerly await any advice Ethan,

    Many thanks,

    Tim

    Thread Starter timmy321

    (@timmy321)

    Hi Perry,

    I wouldn’t say this topic is resolved yet as I would like to know if it is possible to achieve what I want to with the search button without writing my own Javascript?

    If you see the examples I have provided I feel they will be a better example than me trying to describe it.

    https://www.aldi.co.uk/store-finder

    https://www.hussle.com/

    Please can anyone advice? This is pretty much the only thing I’m waiting on before I start to populate my map, as if I cannot achieve this I’ll have to figure out a different way.

    Many thanks in advance,

    Tim

    Hi @timmy321

    We understand what you are trying to achieve here, unfortunately it’s not possible “out of the box” with our plugin.

    If you are able to set up the form on your home page, set up your map page, and provide us with links to both of those pages, then we’d be quite happy to provide JavaScript to marry the two up, if that would help?

    Kind regards
    – Perry

    Thread Starter timmy321

    (@timmy321)

    Ah ok,

    Thank you for your kind offer Perry! I will definitely take you up on that 🙂

    However firstly, I don’t know how to separate the search function from the map, as I just copy/paste the shortcode [wpgmza id=”1″] into the button on the homepage.

    This brings up both the search and map and looks somewhat untidy on the homepage itself:

    https://findgyms.co.uk/

    This is the ‘map’ page’:

    https://findgyms.co.uk/gym-locator/

    Any suggestions on how to separate the search and map?

    Many thanks for bearing with me!

    Tim

    Hi @timmy321

    Please firstly go to Maps -> Settings -> Advanced and under the Custom CSS field, please paste the following:

    body.page-id-4 #wpgmza_map,
    	body.page-id-4 .wpgmza_map
    {
    	display: none !important;
    }

    On the same page, please then paste the following into Custom JS:

    jQuery(function($) {
    
    	if(!window.WPGMZA)
    		return;
    
    	$("body.page-id-4 input.wpgmza-search").off("click");
    	$("body.page-id-4 input.wpgmza-search").on("click", function(event) {
    	
    		var address		= $("input.wpgmza-address").val();
    		var radius		= $("select.wpgmza-radius").val();
    		
    		window.location.href = 
    			"/gym-locator?address=" 
    			+ encodeURIComponent(address) 
    			+ "&radius=" 
    			+ encodeURIComponent(radius);
    	
    	});
    	
    	var address, radius;
    	
    	if(address = WPGMZA.getQueryParamValue("address") && radius = WPGMZA.getQueryParamValue("radius"))
    	{
    		$("input.wpgmza-address").val(address);
    		$("select.wpgmza-radius").val(radius);
    		
    		$("input.wpgmza-search").click();
    	}
    
    });

    Please confirm that works as expected?

    Kind regards
    – Perry

    Thread Starter timmy321

    (@timmy321)

    Hi Perry,

    Thank you very much for putting some time into this!

    I’ve done exactly as you say, but unfortunately not seen any effect.

    I’m using the Astra Theme, with Elementor free version for this page. Could that be the reason this didn’t work?

    Many thanks,

    Tim

    Hi @timmy321

    Thank you for that, I do beg your pardon – I made a small mistake there,

    Please can you change the line

    if(address = WPGMZA.getQueryParamValue("address") && radius = WPGMZA.getQueryParamValue("radius"))

    to

    if((address = WPGMZA.getQueryParamValue("address")) && (radius = WPGMZA.getQueryParamValue("radius")))

    If you replace that line then the code should work as expected. Your theme and Elementor shouldn’t have any effect on this at all.

    Kind regards
    – Perry

    Thread Starter timmy321

    (@timmy321)

    Hi Perry,

    I really am sorry to be a pain mate but that doesn’t seem to have had an effect either. I’ve copied this from what I’ve stuck in and it looks like the same as you suggest?

    In Custom CSS:

    body.page-id-4 #wpgmza_map,
    body.page-id-4 .wpgmza_map
    {
    display: none !important;
    }

    and:

    In Custom JS:

    jQuery(function($) {

    if(!window.WPGMZA)
    return;

    $(“body.page-id-4 input.wpgmza-search”).off(“click”);
    $(“body.page-id-4 input.wpgmza-search”).on(“click”, function(event) {

    var address = $(“input.wpgmza-address”).val();
    var radius = $(“select.wpgmza-radius”).val();

    window.location.href =
    “/gym-locator?address=”
    + encodeURIComponent(address)
    + “&radius=”
    + encodeURIComponent(radius);

    });

    var address, radius;

    if((address = WPGMZA.getQueryParamValue(“address”)) && (radius = WPGMZA.getQueryParamValue(“radius”)))
    {
    $(“input.wpgmza-address”).val(address);
    $(“select.wpgmza-radius”).val(radius);

    $(“input.wpgmza-search”).click();
    }

    });

    Any more ideas?

    Thank you 🙂

    Tim

    Hi Tim

    No worries, not at all, I promise this will work, it just needs tweaking 🙂

    Please remove all the Custom JS and replace it with this new code:

    jQuery(function($) {
    
    	if(!window.WPGMZA)
    		return;
    
    	$("body.page-id-4 input.wpgmza-search").off("click");
    	$("body.page-id-4 input.wpgmza-search").on("click", function(event) {
    	
    		var address		= $("input.wpgmza-address").val();
    		var radius		= $("select.wpgmza-radius").val();
    		
    		window.location.href = 
    			"/gym-locator?address=" 
    			+ encodeURIComponent(address) 
    			+ "&radius=" 
    			+ encodeURIComponent(radius);
    	
    	});
    	
    	var address, radius;
    	
    	if((address = WPGMZA.getQueryParamValue("address")) && (radius = WPGMZA.getQueryParamValue("radius")))
    	{
    		$("input.wpgmza-address").val(address);
    		$("select.wpgmza-radius").val(radius);
    		
    		$(window).on("load", function(event) {
    			$("input.wpgmza-search").click();
    		});
    	}
    
    });

    I can see you’ve entered the Custom CSS however it isn’t rendered on the page at all, are you using any kind of caching plugin which you might need to clear?

    Kind regards
    – Perry

    Thread Starter timmy321

    (@timmy321)

    Ah, I’m using SiteGround as a host and they have a plugin installed called ‘Purge SG Cache’ – I don’t fully understand it’s purpose but it says it purges stuff every three hours. I’ve just manually purged everything too in light of this.

    I’ve also ‘flushed geocode cache under the maps – advanced – settings mode too.

    Unfortunately, again I can’t see any change with the new code 🙁

    I’ve also got CSS Hero installed as a plugin, I don’t think it could be conflicting because it seems like a really good useful plugin, but could this be causing the css to not render?

    Again, apologies to be a pain!

    Tim

    Hi @timmy321

    From our end, the JavaScript is now working perfectly – typing in an address, eg Bristol, on the home page and clicking search will take me to the Gym Locator page with Bristol in the centre of the map at the radius we selected.

    Please can you confirm that is working as expected at your end?

    I’m not sure why that CSS isn’t being rendered at this stage, we can see it if we read the plugins settings in this pages source code, however for some reason it’s just not being rendered into the page itself.

    Could you try disabling CSS Hero temporarily?

    Kind regards
    – Perry

    Thread Starter timmy321

    (@timmy321)

    However the JS code appears to have an effect 🙂

    When searching on the homepage, it does redirect to the map page! But then on the map page, comes up with an error message: ‘Manchester%2C%20UK not found’ – Manchester being the search location.

    I feel progress in being made! 🙂

    Tim

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Link Store search to homepage button’ is closed to new replies.