Ready to get started?Download WordPress


multiple api's with store locator (2 posts)

  1. phthornton
    Posted 3 years ago #

    Has any one had experience with using multiple api's on viadat's store locator.

    The plugin works great on the principal domain but we now have a parked domain which is calling for a new api key.

    I have the javascript to make the api's available to put on the site but can't find where to put it as the store locator automatically inserts the key when it figures that a page needs it.

    any ideas / help most welcome.

    thanks in advance.


  2. judoman
    Posted 2 years ago #

    I had the same problem and got it working. My solution isn't the most elegant, but it works. BTW, using v1.2.42.1 of the Store Locator (SL) plugin.

    First, the API is stored in the WordPress DB using the following name "store_locator_api_key". So the trick is to search the SL source files for where this key is obtained so that we can override it. It's used in three places:

    1. public_html/wp-content/plugins/store-locator/api-key.php
    2. public_html/wp-content/plugins/store-locator/functions.sl.php
    3. public_html/wp-content/plugins/store-locator/view-locations.php

    The first place is the GUI interface to load the WP DB with the "store_locator_api_key" value. My quick-n-dirty solution is to hardcode the API, so I'm never using the DB value. This means I don't have to touch this file.

    The second place has four entries of the "store_locator_api_key", and the third, one entry. All five of these entries needs to be changed.

    Here's an example of one of the entries:

    I changed it to this:


    The idea is that I'm building an array of key/value pairs, where each key is one of the domain names, and its value is the corresponding API key. The $_SERVER['HTTP_HOST'] in the last line gets the domain the end-user is currently at, thereby providing the key for the array. Whammo, the corresponding API is returned.

    I copied this code five times, once for each of the "store_locator_api_key" entries. I simply changed the variable name to match the entry I replaced. So I used $api_key twice, $api twice, and $slak once.

    Hope this quick-n-dirty hardcode method helps. One caveat is that any upgrade to this plug-in will smash our hard coding. Caveat emptor!

Topic Closed

This topic has been closed to new replies.

About this Topic