• Resolved JmeReddish

    (@jmereddish)


    Is it possible to set up a toggle on the front end so users can toggle between miles or km as their distance unit? We have locations across the globe and want to give our users both options if possible.

    If that’s not do-able does anyone know how I could add the km in parentheses next to each of the miles to at least give people a sense of the distance?

    https://www.ads-software.com/plugins/wp-store-locator/

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

    (@tijmensmit)

    The first option is not possible, but maybe the second one is, I just don’t have time now to look into it. But if you’re comfortable with code, then maybe I can just point you in the right direction?

    Thread Starter JmeReddish

    (@jmereddish)

    Hi Tijmen,
    Thank you for the quick response! Yes I’m comfortable with code if you could point me in the right direction. I did some hunting yesterday to try and find it myself with no luck.

    Plugin Author Tijmen Smit

    (@tijmensmit)

    It’s close to midnight already here, so I will explain how to do it tomorrow ??

    Plugin Author Tijmen Smit

    (@tijmensmit)

    Add this code to the functions.php inside your active theme folder, flush the WPSL transient cache on the settings page ( tools section ), and both the km and miles distance should show up.

    I think the code speaks for itself. The data is added in the template on line 61 – 63.

    Plugin Author Tijmen Smit

    (@tijmensmit)

    You can also if you want to use the wpsl_store_meta filter to check the country of the location ( $store_meta[‘country’] ), and based on that value set it to miles or km.

    Plugin Author Tijmen Smit

    (@tijmensmit)

    One other thing I just realized is that the directions that are shown in the store locator itself will always use either km or miles, and there is no way to change that without editing the JS files yourself.

    So if you are going to show km / miles in the search results, or make it depended on what country the location is located in. Then maybe it’s a good idea to make sure the driving directions are shown on Google Maps itself. They detect the country you want to directions for, and will automatically use miles / km when showing the directions.

    Thread Starter JmeReddish

    (@jmereddish)

    Hey,

    Thank you so much for this fantastic explanation! That was a big help and the code allowed me to make a couple other customizations I was hoping to do. ??

    One follow up question though….for the Store Locator plugin obviously there is only one “Settings” page where I’ve set the unit of measurement to miles. You’ve helped give me a workaround to include km in the distance for each location but I’m wondering if I can take it a step further. Would it be possible to load the plugin on a page and specify which unit of measurement to use either in the shortcode or somewhere else in the plugin files?

    So for example – if I wanted to create a duplicate page and direct all of our km using clients there using a different link [www.website.com/non-us], could I load the store locator on that page using km and still keep miles in the dropdown in my initial page? Or can I only have 1 dropdown unit per plugin instance?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Ability to toggle the distance units?’ is closed to new replies.