<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	 xmlns:media="http://search.yahoo.com/mrss/" >

<channel>
	<title>Hooks &amp; Filters &#8211; Agile Store Locator WordPress Plugin</title>
	<atom:link href="https://agilestorelocator.com/wiki/agile-store-locator/hooks-filters/feed/" rel="self" type="application/rss+xml" />
	<link>https://agilestorelocator.com</link>
	<description>#1 Store Locator WordPress Plugin that finds location using the Google Maps</description>
	<lastBuildDate>Wed, 28 Jan 2026 10:33:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Integrating WPForms with Agile Store Locator</title>
		<link>https://agilestorelocator.com/wiki/integrating-wpforms-with-agile-store-locator/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 01 Mar 2024 07:57:38 +0000</pubDate>
				<guid isPermaLink="false">https://agilestorelocator.com/?post_type=docs&#038;p=3488</guid>

					<description><![CDATA[Agile Store Locator integrates with WPForms to capture leads and automatically route notifications to the correct store owner. This integration is available since ASL v4.10.1 Important: WPForms “Hidden Field” is only available in WPForms Pro.Since ASL v5.1.8, you can use a Single Line Text field instead (works in WPForms Lite/free as well). Step 1: Add ... <br><a href="https://agilestorelocator.com/wiki/integrating-wpforms-with-agile-store-locator/" class="text-muted readmore">Read More <i data-feather="chevron-right" class="fea icon-sm"></i></a>]]></description>
										<content:encoded><![CDATA[
<p>Agile Store Locator integrates with WPForms to capture leads and automatically route notifications to the correct store owner. This integration is available since <strong>ASL v4.10.1</strong></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><strong>Important:</strong> WPForms “Hidden Field” is only available in <strong>WPForms Pro</strong>.<br>Since <strong>ASL v5.1.8</strong>, you can use a <strong>Single Line Text</strong> field instead (works in WPForms Lite/free as well).</p>



<p></p>
</blockquote>



<p><strong>Step 1: Add the <code class="" data-line="">asl_store_id</code> Field in WPForms (Pro + Free Options)</strong></p>



<p>Create a field in your WPForms form that will hold the Store ID.</p>



<p><strong>Option A (WPForms Pro) — Hidden Field</strong></p>



<ul class="wp-block-list">
<li>Add a <strong>Hidden Field</strong></li>



<li>Set the <strong>Field Label</strong> to: <code class="" data-line="">asl_store_id</code></li>
</ul>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="1024" height="216" src="https://agilestorelocator.com/wp-content/uploads/2024/03/wpform-hidden-field-1024x216.png" alt="wpform hidden field" class="wp-image-3490" title="Integrating WPForms with Agile Store Locator 1" srcset="https://agilestorelocator.com/wp-content/uploads/2024/03/wpform-hidden-field-1024x216.png 1024w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpform-hidden-field-300x63.png 300w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpform-hidden-field-768x162.png 768w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpform-hidden-field-1536x324.png 1536w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpform-hidden-field-360x76.png 360w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpform-hidden-field-350x74.png 350w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpform-hidden-field-76x16.png 76w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpform-hidden-field.png 1541w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><strong>Option B (WPForms Lite/Free) — Single Line Text Field (ASL v5.1.8+)</strong></p>



<ul class="wp-block-list">
<li>Add a <strong>Single Line Text</strong> field</li>



<li>Set the <strong>Field Label</strong> to: <code class="" data-line="">asl_store_id</code></li>



<li>Open <strong>Advanced</strong> settings for that field and set <strong>CSS Classes</strong> to: <code class="" data-line="">asl-hidden-store-id</code></li>
</ul>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="383" height="228" src="https://agilestorelocator.com/wp-content/uploads/2024/03/add-class-wp-form-field.png" alt="add class wpform field" class="wp-image-4198" title="Integrating WPForms with Agile Store Locator 2" srcset="https://agilestorelocator.com/wp-content/uploads/2024/03/add-class-wp-form-field.png 383w, https://agilestorelocator.com/wp-content/uploads/2024/03/add-class-wp-form-field-300x179.png 300w, https://agilestorelocator.com/wp-content/uploads/2024/03/add-class-wp-form-field-360x214.png 360w, https://agilestorelocator.com/wp-content/uploads/2024/03/add-class-wp-form-field-350x208.png 350w, https://agilestorelocator.com/wp-content/uploads/2024/03/add-class-wp-form-field-76x45.png 76w" sizes="(max-width: 383px) 100vw, 383px" /></figure>
</div>


<p><strong>Optional (recommended): hide the text field using CSS</strong> (so users don’t see it):</p>



<pre class="wp-block-prismatic-blocks"><code class="language-css" data-line="">.wpforms-field.asl-hidden-store-id {
  display: none !important;
}</code></pre>



<p><strong>Step 2: Enabling WPForms Hook in Agile Store Locator Settings</strong></p>



<p>Navigate to the Agile Store Locator Settings and head to the Notification tab. Enable the WPForms hook to activate the integration between Agile Store Locator and WPForms.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="264" src="https://agilestorelocator.com/wp-content/uploads/2024/03/enable-wpforms-notify-1024x264.png" alt="enable wpforms notify" class="wp-image-3491" title="Integrating WPForms with Agile Store Locator 3" srcset="https://agilestorelocator.com/wp-content/uploads/2024/03/enable-wpforms-notify-1024x264.png 1024w, https://agilestorelocator.com/wp-content/uploads/2024/03/enable-wpforms-notify-300x77.png 300w, https://agilestorelocator.com/wp-content/uploads/2024/03/enable-wpforms-notify-768x198.png 768w, https://agilestorelocator.com/wp-content/uploads/2024/03/enable-wpforms-notify-360x93.png 360w, https://agilestorelocator.com/wp-content/uploads/2024/03/enable-wpforms-notify-350x90.png 350w, https://agilestorelocator.com/wp-content/uploads/2024/03/enable-wpforms-notify-76x20.png 76w, https://agilestorelocator.com/wp-content/uploads/2024/03/enable-wpforms-notify.png 1325w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><strong>Option 1: Using a Separate Lead Form</strong></p>



<p>If you prefer to use a separate lead form, simply provide the store ID to the hidden &#8220;asl_store_id&#8221; field within the WPForms label. When a lead is captured through this form, the email notification will be sent directly to the store owner associated with the specified store ID.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="1004" height="200" src="https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-store-id.png" alt="wpforms store id" class="wp-image-3492" title="Integrating WPForms with Agile Store Locator 4" srcset="https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-store-id.png 1004w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-store-id-300x60.png 300w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-store-id-768x153.png 768w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-store-id-360x72.png 360w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-store-id-350x70.png 350w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-store-id-76x15.png 76w" sizes="auto, (max-width: 1004px) 100vw, 1004px" /></figure>
</div>


<p><strong>Option 2: Including a Call-to-Action (CTA) Button in Store Locator Listing</strong></p>



<p>Alternatively, you can include a Call-to-Action (CTA) button in the store locator listing. When users click on this button, it opens a form containing the WPForms integration. This form will automatically populate the &#8220;asl_store_id&#8221; field with the corresponding store ID. Upon submission, the email notification will be sent to the respective store owner, to integrate the lead form as a CTA, follow the steps below:</p>



<p>1- Add the WPForms ID in the shortcode as the WPForms attribute.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">[ASL_STORELOCATOR wpforms=&quot;3039&quot;]</code></pre>



<p>3- Make sure that the hidden field has the CSS Classes as <code class="" data-line="">asl_store_id</code> in the form.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="187" src="https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-class-needed-1024x187.png" alt="wpforms class needed" class="wp-image-3494" title="Integrating WPForms with Agile Store Locator 5" srcset="https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-class-needed-1024x187.png 1024w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-class-needed-300x55.png 300w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-class-needed-768x140.png 768w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-class-needed-360x66.png 360w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-class-needed-350x64.png 350w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-class-needed-76x14.png 76w, https://agilestorelocator.com/wp-content/uploads/2024/03/wpforms-class-needed.png 1334w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>2- Add a call to action through the <a href="https://agilestorelocator.com/wiki/customization-of-store-locator/">Store Locator List Customization</a>.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-markup" data-line="">&lt;a class=&quot;btn btn-asl asl-lead-cta-btn&quot;&gt;[Contact Store]&lt;/a&gt;</code></pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="771" height="433" src="https://agilestorelocator.com/wp-content/uploads/2024/03/lead-form-cta.png" alt="lead form cta" class="wp-image-3493" title="Integrating WPForms with Agile Store Locator 6" srcset="https://agilestorelocator.com/wp-content/uploads/2024/03/lead-form-cta.png 771w, https://agilestorelocator.com/wp-content/uploads/2024/03/lead-form-cta-300x168.png 300w, https://agilestorelocator.com/wp-content/uploads/2024/03/lead-form-cta-768x431.png 768w, https://agilestorelocator.com/wp-content/uploads/2024/03/lead-form-cta-360x202.png 360w, https://agilestorelocator.com/wp-content/uploads/2024/03/lead-form-cta-350x197.png 350w, https://agilestorelocator.com/wp-content/uploads/2024/03/lead-form-cta-76x43.png 76w" sizes="auto, (max-width: 771px) 100vw, 771px" /></figure>
</div>


<p>By leveraging this integration, you can streamline lead capture processes and ensure timely communication between customers and store owners.</p>



<h4 class="wp-block-heading" id="h-how-to-include-a-lead-form-on-the-store-detail-page">How to include a Lead Form on the Store Detail page?</h4>



<p>Agile Store Locator does support including a lead form that will send emails to the store of the listed page detail, Integrating a lead form with <a href="https://wpforms.com/" target="_blank" rel="noopener">WPForms</a> on the store detail page is a seamless process. Follow these steps to set it up:</p>



<ol class="wp-block-list">
<li><strong>Add WPForms Shortcode</strong>: On the store detail page where you want to include the lead form, insert the WPForms shortcode. This shortcode allows you to display the form on the desired page.</li>



<li><strong>Hidden Field</strong>: Add a hidden field with the label <code class="" data-line="">asl_store_id</code> in the WPForms form.</li>



<li><strong>Enable WPForms Hook</strong>: In the ASL Settings, navigate to the Notifications tab. Locate the option to enable the WPForms hook and toggle it on. This step ensures that emails generated from the lead form submission are sent to the respective store owners.</li>
</ol>



<p>By completing these steps, you can easily incorporate a lead form powered by WPForms into your Agile Store Locator store detail pages, facilitating seamless communication between users and store owners.</p>



<h3 class="wp-block-heading">How to Check If Emails Are Being Sent</h3>



<p>If store owners are not receiving emails, first confirm whether WordPress is sending them.</p>



<ol class="wp-block-list">
<li>Install and activate <strong>WP Mail Logging</strong><br><a href="https://wordpress.org/plugins/wp-mail-logging/" target="_blank" rel="noreferrer noopener nofollow">https://wordpress.org/plugins/wp-mail-logging/</a></li>



<li>Submit the store contact / lead form.</li>



<li>Go to <strong>WordPress Admin → WP Mail Logging</strong> and check the latest email entry.</li>
</ol>



<h3 class="wp-block-heading">How to Read the Result</h3>



<ul class="wp-block-list">
<li><strong>Email appears in the log</strong> → WordPress sent the email successfully. Check spam folder or configure SMTP.</li>



<li><strong>Email does not appear</strong> → The email was not triggered. Verify:
<ul class="wp-block-list">
<li><code class="" data-line="">asl_store_id</code> field exists and is populated</li>



<li>WPForms hook is enabled in <strong>ASL Settings → Notifications</strong></li>



<li>Correct WPForms ID is used in the shortcode</li>
</ul>
</li>
</ul>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Store Locator WordPress Hooks/Filters</title>
		<link>https://agilestorelocator.com/wiki/store-locator-wordpress-hooks-filters/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 10 Nov 2022 07:37:34 +0000</pubDate>
				<category><![CDATA[wiki]]></category>
		<guid isPermaLink="false">https://agilestorelocator.com/?p=2867</guid>

					<description><![CDATA[Store Locator for WordPress offers multiple hooks or filters to change the behavior of the event or change in the dataset, below are the available filters that can be used in WordPress. List of Store Locator Filters Filter Description asl_filter_stores_result The purpose of the above filter is to change the dataset of the stores that ... <br><a href="https://agilestorelocator.com/wiki/store-locator-wordpress-hooks-filters/" class="text-muted readmore">Read More <i data-feather="chevron-right" class="fea icon-sm"></i></a>]]></description>
										<content:encoded><![CDATA[
<p>Store Locator for WordPress offers multiple hooks or filters to change the behavior of the event or change in the dataset, below are the available filters that can be used in WordPress.</p>



<h3 class="wp-block-heading" id="h-list-of-store-locator-filters">List of Store Locator Filters</h3>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Filter</strong></td><td><strong>Description</strong></td></tr><tr><td>asl_filter_stores_result</td><td>The purpose of the above filter is to change the dataset of the stores that are thrown to the store locator in JSON format.</td></tr><tr><td>asl_filter_locator_attrs</td><td>To change the shortcode attributes of the store locator, for example, you want to hide the list of the store locator via a hook, that can be performed with it.</td></tr><tr><td>asl_filter_locator_words</td><td>In case you want to change or replace any word text of the store locator that is injected in the JS file, it can be done via this filter without modifying any core file.</td></tr><tr><td>asl_filter_search_widget_words</td><td>In case you want to change or replace any word text of the Search widget can be done via this filter.</td></tr><tr><td>asl_parse_csv</td><td>This filter can be used to manipulate the data before it is imported via the CSV importer tool.</td></tr><tr><td>asl_woocommerce_store_settings</td><td>This filter is being used in the <a href="https://agilestorelocator.com/multistore-woocommerce-addons/">Multi-Store Addons for WooCommerce</a> before the Store data is saved through the form.</td></tr><tr><td>asl_filter_store_detail</td><td>This filter will be fired when the store detail widget is being used on some page.</td></tr><tr><td>asl_filter_store_form</td><td>This filter will be fired during the rendering of the Store Registration form, you can change the configuration of the form using it.</td></tr><tr><td>asl_filter_locator_config</td><td>This filter will be fired before the rendering of the Store Locator, you can tweak the configs using it.</td></tr><tr><td>asl_filter_pre_register_store</td><td>This filter will be fired before the store registration form values are saved, so you can manipulate the data before saving it, since version (4.9.15)</td></tr><tr><td>asl_action_store_registered</td><td>This action will be fired after the store registration form is saved, it provides the ID of the saved store, since version (4.9.15)</td></tr><tr><td>asl_before_stores_import</td><td>An action that executes before the import of the CSV file, you can delete existing stores as given in the example below, since version (4.9.15)</td></tr><tr><td>asl_filter_pre_insert_store</td><td>This filter can be used to modify the store data before it is being inserted, since version (4.9.19)</td></tr><tr><td>asl_filter_pre_update_store</td><td>This filter can be used to modify the store data before it is being updated, since version (4.9.19)</td></tr><tr><td>asl_filter_locator_categories</td><td>This filter can be used to manipulate the categories data for the store locator, available since version (4.9.15)</td></tr><tr><td>asl_filter_locator_attributes</td><td>This filter can be used to remove brand options that are not present in the `wp_asl_stores` table, available since (4.10.15)</td></tr></tbody></table><figcaption class="wp-element-caption">Filter Hooks Table</figcaption></figure>



<h3 class="wp-block-heading" id="h-how-to-use-the-above-filters">How to use the above filters?</h3>



<p>The above filters can be used in the functions.php file of your active theme, below is an example of the filter usage.</p>



<p>In this example, we have changed the category id to the category name, that is used in the query parameter.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">/**
 * [asl_filter_locator_method description]
 * @param  [type] $attrs [description]
 * @return [type]        [description]
 */
function asl_filter_locator_method($attrs) {

	global $wpdb;

	$q_category = isset($_GET[&#039;locator-category&#039;]) &amp;&amp; $_GET[&#039;locator-category&#039;]? $_GET[&#039;locator-category&#039;]: null;

	if($q_category) {

		$locator_category = $wpdb-&gt;get_results($wpdb-&gt;prepare(&quot;SELECT * FROM &quot;.ASL_PREFIX.&quot;categories WHERE category_name = %s&quot;, $q_category));

		if($locator_category &amp;&amp; isset($locator_category[0])) {

			$attrs[&#039;select_category&#039;] = $locator_category[0]-&gt;id;
		}
	}

	return $attrs;
};

add_filter(&#039;asl_filter_locator_attrs&#039;, &#039;asl_filter_locator_method&#039;);</code></pre>



<h4 class="wp-block-heading" id="h-apply-your-own-css-file-for-the-search-widget">Apply your own CSS file for the Search Widget</h4>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">/**
 * [asl_filter_search_widget_words_method Used this filter to change the CSS file]
 * @param  [type] $words [description]
 * @return [type]        [description]
 */
function asl_filter_search_widget_words_method($words) {

	//	Dequeue the plugin search css file
  wp_dequeue_style(&#039;agile-store-locator-asl-search&#039;);
  	
  //	Add your customized search file
  wp_enqueue_style(&#039;asl-search-widget&#039;,  get_template_directory_uri().&#039;/asl_search-updated.css&#039;, array(), &#039;4.9.12&#039;, &#039;all&#039; );

	return $words;
}

add_filter(&#039;asl_filter_search_widget_words&#039;, &#039;asl_filter_search_widget_words_method&#039;);</code></pre>



<h3 class="wp-block-heading" id="h-store-results-filter-to-manipulate-or-change-the-store-data">Store Results Filter to Manipulate or Change the Store Data</h3>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">
/**
 * [asl_add_additional_column Use this Method to add a new field to the data]
 * @param  [type] $all_stores [description]
 * @return [type]             [description]
 */
function asl_add_additional_column($all_stores) {

  foreach($all_stores as $store) {

    $store-&gt;agent = &#039;John Doe&#039;;
  }

  return $all_stores;
}

add_filter(&#039;asl_filter_stores_result&#039;, &#039;asl_add_additional_column&#039;);
</code></pre>



<p>Another example of asl_filter_stores_result is to through the data from some API or custom CPT.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">/**
 * [asl_add_additional_column Custom data rendered using CPT or API endpoint]
 * @param  [type] $all_stores [description]
 * @return [type]             [description]
 */
function asl_stores_custom_data($all_stores) {

	//	Array of stores
	$my_stores = [];

	//	Add the Store 1
	//$my_stores[]

	//	Add the Store 2
	//$my_stores[]

  return $my_stores;
}

add_filter(&#039;asl_filter_stores_result&#039;, &#039;asl_stores_custom_data&#039;);</code></pre>



<p>Truncate/Delete all my existing stores data before the import process</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">// Delete all my stores before the import of new files, Tested with version 4.9.15
add_action(&#039;asl_before_stores_import&#039;, function() {

	//	Create an instance
	$store_inst = new \AgileStoreLocator\Admin\Store();
	
	// Must be returned as object, else it will die
	$store_inst-&gt;as_object = true;

	//	Yes, delete everything, CAN&#039;T be restored!
	$store_inst-&gt;admin_delete_all_stores();
});
</code></pre>



<h4 class="wp-block-heading">Add <code class="" data-line="">phone_raw</code> on PHP Side</h4>



<p>To use a clean phone number for <code class="" data-line="">tel:</code> links, you can add a <code class="" data-line="">phone_raw</code> field on the PHP side using the <code class="" data-line="">asl_filter_stores_result</code> filter:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">function asl_add_additional_column($all_stores) {
    foreach ($all_stores as $store) {
        $store-&gt;phone_raw = !empty($store-&gt;phone) ? preg_replace(&#039;/\D+/&#039;, &#039;&#039;, $store-&gt;phone) : &#039;&#039;;
    }
    return $all_stores;
}
add_filter(&#039;asl_filter_stores_result&#039;, &#039;asl_add_additional_column&#039;);
</code></pre>



<p>Now you can safely do:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-markup" data-line="">{{if phone}}
&lt;li class=&quot;sl-phone&quot;&gt;
    &lt;i class=&quot;icon-mobile&quot;&gt;&lt;/i&gt;
    &lt;a href=&quot;tel:{{:phone_raw}}&quot;&gt;{{:phone}}&lt;/a&gt;
&lt;/li&gt;
{{/if}}</code></pre>



<h3 class="wp-block-heading" id="h-modifying-the-store-data-on-insertion-update">Modifying the Store data on insertion/update</h3>



<p>Using the filter below, one can easily manipulate the store data before it is being saved, in the example we have removed the https:// on the website field.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">// Pre-insert store method to make modification to the data
add_filter(&#039;asl_filter_pre_insert_store&#039;, function ($form_data) {
	
	// Remove &quot;https://&quot;
	$form_data[&#039;website&#039;] = str_replace(&quot;https://&quot;, &quot;&quot;, $form_data[&#039;website&#039;]);

  return $form_data;
});</code></pre>



<p>The same method as above except this time it is for update store instead of insertion.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">// Pre-update store method to make modification to the data
add_filter(&#039;asl_filter_pre_update_store&#039;, function ($form_data, $store_id) {

  // Remove &quot;https://&quot;
	$form_data[&#039;website&#039;] = str_replace(&quot;https://&quot;, &quot;&quot;, $form_data[&#039;website&#039;]);

  return $form_data;

}, 10, 2);</code></pre>



<h3 class="wp-block-heading" id="h-perform-wpml-translate-to-the-stores-categories-via-wpml">Perform WPML Translate to the Stores Categories via WPML</h3>



<p>The filter <code class="" data-line="">asl_filter_locator_categories</code> can be utilized to translate the categories through string translation.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">/**
 * [translate_asl_categories_via_wpml Translate ASL Categories via WPML]
 * @param  [type] $catgories [description]
 * @return [type]            [description]
 */
function translate_asl_categories_via_wpml($catgories) {

	//	Loop over the categories
	foreach($catgories as $sl_category) {

		//	Pass through translation string
		$sl_category-&gt;name = esc_attr__($sl_category-&gt;name,&#039;asl_locator&#039;);
	}

	return $catgories;
};

add_filter(&#039;asl_filter_locator_categories&#039;, &#039;translate_asl_categories_via_wpml&#039;);</code></pre>



<h3 class="wp-block-heading" id="h-run-execute-shortcode-in-the-stores-listing">Run/Execute Shortcode in the Stores Listing</h3>



<p>In this example, we will explain how you can execute a shortcode in the stores listing, we will use <a href="https://wpdatatables.com/" target="_blank" rel="noopener">wpdatatables</a>, which is a well-known WordPress plugin.</p>



<ol class="wp-block-list">
<li>Create a custom field in the ASL Settings, and name the field <strong>table_id</strong>.<br><img loading="lazy" decoding="async" width="1208" height="283" class="wp-image-3570" style="" src="https://agilestorelocator.com/wp-content/uploads/2022/11/add-field.png" alt="add field" title="Store Locator WordPress Hooks/Filters 7" srcset="https://agilestorelocator.com/wp-content/uploads/2022/11/add-field.png 1208w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-field-300x70.png 300w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-field-1024x240.png 1024w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-field-768x180.png 768w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-field-360x84.png 360w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-field-350x82.png 350w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-field-76x18.png 76w" sizes="auto, (max-width: 1208px) 100vw, 1208px" /></li>



<li>Add the table ID for the store that you want to render the table.<br><img loading="lazy" decoding="async" width="809" height="568" class="wp-image-3571" style="" src="https://agilestorelocator.com/wp-content/uploads/2022/11/add-table-field-value.png" alt="add table value" title="Store Locator WordPress Hooks/Filters 8" srcset="https://agilestorelocator.com/wp-content/uploads/2022/11/add-table-field-value.png 809w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-table-field-value-300x211.png 300w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-table-field-value-768x539.png 768w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-table-field-value-360x253.png 360w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-table-field-value-350x246.png 350w, https://agilestorelocator.com/wp-content/uploads/2022/11/add-table-field-value-76x53.png 76w" sizes="auto, (max-width: 809px) 100vw, 809px" /></li>



<li>Add this code to your functions.php</li>
</ol>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">/**
 * [asl_add_additional_column Use this Method to run a shortcode]
 * @param  [type] $all_stores [description]
 * @return [type]             [description]
 */
function asl_add_shortcode_to_listing($all_stores) {

  foreach($all_stores as $store) {
 
    if($store-&gt;table_id) {
      $store-&gt;description = $store-&gt;description.do_shortcode(&#039;[wpdatatable id=&#039;.$store-&gt;table_id.&#039; table_view=regular]&#039;);
    }
  }
  return $all_stores;
}
add_filter(&#039;asl_filter_stores_result&#039;, &#039;asl_add_shortcode_to_listing&#039;);</code></pre>



<h3 class="wp-block-heading" id="h-manipulate-content-of-csv-file-during-import">Manipulate Content of CSV File During Import</h3>



<p>The import process has a WordPress filter <code class="" data-line="">asl_parse_csv</code> that can be used to change or manage the content at the time of import, such as you need to change the country name from <strong>US</strong> to <strong>United States</strong> from the country column, as the United States is the accepted country name from the <a href="https://agilestorelocator.com/wiki/list-of-countries/">list of countries</a>.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">/**
 * [asl_parse_csv_method Manipulate the CSV import data]
 * @param  [type] $csv [description]
 * @return [type]      [description]
 */
function asl_parse_csv_method($csv) {

	//	Get the rows
	$rows = $csv-&gt;getRows();

	//	Loop over the rows
	foreach($rows as &amp;$row) {

		// Change the country name
		if($row[6] == &#039;South Africa&#039;) {
			$row[6] = &#039;France&#039;;
		} 
	}

	//	Put it back
	$csv-&gt;setRows($rows);

	return $csv;
}


add_filter(&#039;asl_parse_csv&#039;, &#039;asl_parse_csv_method&#039;);</code></pre>



<h3 class="wp-block-heading" id="h-manipulate-content-of-csv-file-during-import">Change the Load Stores Query via Filter</h3>



<p>The <code class="" data-line="">asl_filter_stores_query_full</code> filter allows developers to modify the query used for loading store data. This can be useful when you need to adjust the query to suit specific needs.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">add_filter(&#039;asl_filter_stores_query_full&#039;, &#039;modify_asl_stores_query&#039;, 10, 1);

function modify_asl_stores_query($query) {
    // Replace all occurrences of 30000 with 40000 in the query
    $query = str_replace(&#039;30000&#039;, &#039;40000&#039;, $query);

    // Return the modified query
    return $query;
}</code></pre>



<h3 class="wp-block-heading">Filter to remove unnecessary brand options from the dropdown</h3>



<p>This filter can be used to remove brand and special options that are not present in the&nbsp;<code class="" data-line="">wp_asl_stores</code>&nbsp;table. It ensures that only the relevant options are displayed in the dropdown menus.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">/**
 * Filter to remove unnecessary brand options from the dropdown.
 *
 * This filter can be used to remove brand options that are not present in the `wp_asl_stores` table.
 *
 * @param array $attributes The attributes array containing the brand list.
 * @return array The filtered attributes array with only the necessary brand options.
 */
add_filter(&#039;asl_filter_locator_attributes&#039;, function ($attributes) {

    global $wpdb;

    $ASL_PREFIX = $wpdb-&gt;prefix.&#039;asl_&#039;; // Assuming the prefix is &#039;wp_asl_&#039;

    // Step 1: Extract brand IDs
    $brand_list = $attributes[&#039;brand&#039;];

    $brand_ids = array_map(function ($brand) {
        return $brand-&gt;id;
    }, $brand_list);

    // Step 2: Query the wp_asl_stores table to get the list of brand IDs
    $query = &quot;SELECT brand FROM {$ASL_PREFIX}stores as s&quot;;
    $result = $wpdb-&gt;get_results($query);

    $store_brand_ids = [];
    foreach ($result as $row) {
        $store_brand_ids = array_merge($store_brand_ids, explode(&#039;,&#039;, $row-&gt;brand));
    }

    $store_brand_ids = array_unique($store_brand_ids);

    // Step 3: Filter the original brand list
    $filtered_brand_list = array_filter($brand_list, function ($brand) use ($store_brand_ids) {
        return in_array($brand-&gt;id, $store_brand_ids);
    });

    // Step 4: Update the $attributes[&#039;brand&#039;] array
    $attributes[&#039;brand&#039;] = $filtered_brand_list;

    return $attributes;
});</code></pre>



<h3 class="wp-block-heading">Change CSV Header Fields to Custom</h3>



<p>Use the <code class="" data-line="">asl_parse_csv</code> filter to modify CSV headers before importing into Agile Store Locator.<br>This is useful for mapping third-party or localized column names to ASL’s required keys.<br>For example, convert <code class="" data-line="">Straße</code> to <code class="" data-line="">street</code>, <code class="" data-line="">PLZ</code> to <code class="" data-line="">postal_code</code>, and <code class="" data-line="">Ort</code> to <code class="" data-line="">city</code> automatically during import.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">
/**
 * Normalize incoming CSV headers to ASL&#039;s accepted column names.
 * Converts German headers to ASL standard:
 *   - &quot;Straße&quot;/&quot;Strasse&quot; -&gt; &quot;street&quot;
 *   - &quot;PLZ&quot;              -&gt; &quot;postal_code&quot;
 *   - &quot;Ort&quot;              -&gt; &quot;city&quot;
 *
 * Only the first row (header) is modified; data rows remain unchanged.
 */
function asl_change_header_column_fields($csv) {

	// Get all CSV rows (row 0 is the header)
	$rows = $csv-&gt;getRows();

	if (!empty($rows) &amp;&amp; is_array($rows[0])) {

			// Map of accepted synonyms -&gt; ASL standard header
			// Keys are lowercase for case-insensitive matching
			$header_map = array(
					&#039;straße&#039;  =&gt; &#039;street&#039;,
					&#039;plz&#039;     =&gt; &#039;postal_code&#039;,
					&#039;ort&#039;     =&gt; &#039;city&#039;,
			);

			// Loop header cells and normalize
			foreach ($rows[0] as $i =&gt; $header) {

					// Trim spaces; lower-case for matching (mb_ safe if available)
					$trimmed = trim($header);
					$key = function_exists(&#039;mb_strtolower&#039;) ? mb_strtolower($trimmed, &#039;UTF-8&#039;) : strtolower($trimmed);

					// If it&#039;s a known synonym, replace with ASL standard
					if (isset($header_map[$key])) {
							$rows[0][$i] = $header_map[$key];
					}
					// Else leave as-is (already standard or a different column)
			}
	}

	// Put rows back
	$csv-&gt;setRows($rows);

	return $csv;
}

// Hook into ASL CSV parsing
add_filter(&#039;asl_parse_csv&#039;, &#039;asl_change_header_column_fields&#039;);</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Apply Javascript Hooks</title>
		<link>https://agilestorelocator.com/wiki/how-to-apply-hooks/</link>
		
		<dc:creator><![CDATA[Talha Nadeem]]></dc:creator>
		<pubDate>Tue, 24 Aug 2021 05:33:00 +0000</pubDate>
				<category><![CDATA[wiki]]></category>
		<guid isPermaLink="false">https://agilestorelocator.com/?p=1970</guid>

					<description><![CDATA[Some users may require “hooks” to record certain activities on the store locator. For example, a user may need hooks for direction, Icons, lists Items, searches, navigation, etc. Furthermore, hooks are a very useful tool that will make your store locator more versatile.]]></description>
										<content:encoded><![CDATA[
<p>Some users may require “hooks” to record certain activities on the store locator. For example, a user may need hooks for directions, Icons, lists, Items, searches, navigation,<strong> </strong>etc. Furthermore, hooks are a very useful tool that will make your store locator more versatile.</p>



<p>Therefore, we have added the hook feature so that it will activate whenever any event occurs on the store locator, such as:</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Event Type</strong></td><td><strong>Description</strong></td></tr><tr><td>init</td><td>When the store locator is initialized.</td></tr><tr><td>load</td><td>When the store locator data is loaded.</td></tr><tr><td>search</td><td>When a search is performed</td></tr><tr><td>clear</td><td>When the address search is cleared (since version 4.8.20)</td></tr><tr><td>beforeclear</td><td>When the address search is cleared but before the list is recompiled (since version 4.8.20)</td></tr><tr><td>select</td><td>When the store is selected <em>(since version 4.8.20)</em></td></tr><tr><td>unselect</td><td>When the store is unselected <em>(since version 4.8.20)</em></td></tr><tr><td>direction</td><td>When the “direction” button is clicked.</td></tr><tr><td>geolocation</td><td>When the geolocation is performed.</td></tr><tr><td>no_stores</td><td>When no stores are found in the search.</td></tr><tr><td>pickup</td><td>When the pickup button is selected during the WooCommerce checkout</td></tr><tr><td>category</td><td>When the category filter is applied.</td></tr><tr><td>addr_ddl_event</td><td>When the address dropdown value is changed (since version 4.10.1)</td></tr><tr><td>before_search</td><td>Before a search is started (since version 4.9.16)</td></tr><tr><td>custom_btn</td><td>Any button in the listing template having CSS class &#8220;sl-btn-custom&#8221; can be used to achieve custom events (since 4.10.5)</td></tr><tr><td>no_stores_filter</td><td>No stores filter is fired when no stores are found in the search, it also return list of stores that can be rendered.</td></tr></tbody></table><figcaption class="wp-element-caption">Event Types of JS</figcaption></figure>



<p>The hook can be added via the below javascript:&nbsp;</p>



<pre class="wp-block-prismatic-blocks"><code class="language-markup" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
function asl_event_hook(_event) {
   
  if(_event.type == &#039;init&#039;) {
    asl_configuration.print_header = &#039;&lt;h3 class=&quot;custom-h3&quot;&gt;Agile Store Locator &lt;img src=&quot;https://agilestorelocator.com/wp-content/themes/sl-theme/images/sl-logo-dark.png&quot;&gt;&lt;/h3&gt;&#039;; // example to override the configuration value
  }
}
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading" id="h-where-should-we-place-this-event-code">Where should we place this event code?</h4>



<p>The provided JavaScript snippet can be easily integrated into your store locator page using a builder like Elementor&#8217;s HTML Widget or another suitable method. </p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="342" height="433" src="https://agilestorelocator.com/wp-content/uploads/2023/10/store-locator-js-snippet.png" alt="store locator js snippet" class="wp-image-3314" title="How to Apply Javascript Hooks 9" srcset="https://agilestorelocator.com/wp-content/uploads/2023/10/store-locator-js-snippet.png 342w, https://agilestorelocator.com/wp-content/uploads/2023/10/store-locator-js-snippet-237x300.png 237w, https://agilestorelocator.com/wp-content/uploads/2023/10/store-locator-js-snippet-208x263.png 208w, https://agilestorelocator.com/wp-content/uploads/2023/10/store-locator-js-snippet-45x57.png 45w" sizes="auto, (max-width: 342px) 100vw, 342px" /></figure>
</div>


<p>Please ensure that the code is placed on the store locator page for it to execute correctly, you can add a console statement in the code to see if it is getting executed or not.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-markup" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
function asl_event_hook(_event) {
   
  console.log(&#039;Yes I am working just fine!&#039;, _event.type);
}
&lt;/script&gt;</code></pre>



<p>As a testing measure, you can directly insert it into the store locator view file located at the following path.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">/agile-store-locator/public/partials/template-frontend-0.php</code></pre>



<p>Assuming you are using Template 0. However, please note that this integration in the plugin view file will be overwritten when you update the plugin.</p>



<h4 class="wp-block-heading" id="h-how-to-override-the-website-button-event-on-the-listing">How to override the website button event on the listing?</h4>



<p>In order to run your javascript when the store locator website button is clicked, you can add this method on the page. Once this function is registered on the page, it will execute instead of redirecting to that website link, it will help perform any other operations.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">/**
 * [asl_website_click ASL Website button Hook]
 * @param  {[type]} store [Store Object]
 * @param  {[type]} link  [Link of the website]
 * @return {[type]}       [description]
 */
function asl_website_click(store,link) {

};</code></pre>



<h4 class="wp-block-heading" id="h-js-hook-usage-example-select-the-first-store-upon-load">JS hook usage example:: Select the first store upon load</h4>



<p>In this example, we have modified the script to highlight the first store on the load.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
function asl_event_hook(_event) {
   
  if(_event.type == &#039;init&#039;) {
    
    window.setTimeout(function(){

      asl_view.highlight(asl_view.stores[0]);
    
    }, 500);
  }
}
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading" id="h-js-hook-usage-example-applying-a-filter-for-the-store-locator-to-always-filter-the-fields">JS hook usage example:: Applying a filter for the store locator to always filter the fields</h4>



<p>In this example, the collect is a custom field, and we have added it on <strong>&#8220;load&#8221;</strong> and <strong>&#8220;beforeclear&#8221;</strong> events, so the list will always apply that collect custom field filter.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
function asl_event_hook(_event) {
   
  if(_event.type == &#039;load&#039; || _event.type == &#039;beforeclear&#039;) {
    
    asl_view.prop_filter = {type: &#039;collect&#039;, title: &#039;1&#039;};
    asl_view.refreshView();
  }
}
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading" id="h-js-hook-usage-example-search-event-data-push-to-google-analytics-ga4">JS hook usage example:: Search Event data push to Google Analytics (GA4)</h4>



<p>I assume that you have already enabled Google Analytics on your page, if not, please make sure that the GA code is added properly and the <strong>dataLayer</strong> variable is accessible, create a custom event using GA4 and push the events like the example below.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
function asl_event_hook(_event) {
   
  if(_event.type == &#039;search&#039;) {
    
    //  applied categories filters
    var active_filters = asl_view.featureFilter.array_.map(function(cat) {return cat.name_;});
    active_filters = active_filters.join(&#039;,&#039;);
    
    var first_store = asl_view.stores[0].props_.title; // in case you want to send the store title
    dataLayer.push({
      &#039;event&#039;: &#039;locator_search_event&#039;, // Replace the event name
      &#039;search_type&#039;: &#039;Address&#039;,
      &#039;search_filters&#039;: active_filters,
      &#039;address_searched&#039;: _event.data.search_text
    });
    
  gtag(&#039;event&#039;, &#039;locator_search&#039;, {});
  }
}
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading" id="h-js-hook-usage-example-reset-map-on-infobox-close">JS hook usage example:: Reset Map on Infobox Close</h4>



<p>In this example, we have modified the script to reset the Google Maps zoom and default coordinates, make sure to have version 4.9.13 as it has improved since that version.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
  function asl_event_hook(_event) {
     
    if(_event.type == &#039;unselect&#039;) {
      
      var the_map = asl_view.getMap();
      the_map.panTo(new google.maps.LatLng(asl_configuration.default_lat, asl_configuration.default_lng));
      the_map.setZoom(parseInt(asl_configuration.zoom));
    }
  }
&lt;/script&gt;</code></pre>



<p><br>If you believe that there are important events missing from our system, please don&#8217;t hesitate to reach out to us. You can contact our support team via email at support@agilelogix.com. We value your feedback and are open to enhancing our offerings to better meet your needs.</p>



<h4 class="wp-block-heading" id="h-js-load-hook-example-pre-select-a-state-from-the-dropdown">JS Load Hook Example:: Pre-Select a State from the Dropdown</h4>



<p>You will pass the state in the query parameter such as <strong><code class="" data-line="">/store-locator/?select-state=NY</code></strong> so that will pre-select that NY state, the code below will only work when we don&#8217;t have the countries dropdown.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
  function asl_event_hook(_event) {

    // Get the value of a specific query parameter using jQuery
    function getQueryParam(parameterName) {
      return new URLSearchParams(window.location.search).get(parameterName);
    }

    var state_parameter = getQueryParam(&#039;select-state&#039;);
    
    if(_event.type == &#039;load&#039; &amp;&amp; state_parameter) {

      var state_to_select = state_parameter;
      jQuery(&#039;#sl-addr-ddl-state&#039;).multiselect(&#039;select&#039;, state_to_select).multiselect(&#039;refresh&#039;);
      asl_view.address_values[&#039;state&#039;] = state_to_select;
      asl_view.refreshView();
    }
  }
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading" id="h-js-load-hook-example-pre-select-values-from-the-address-dropdowns">JS Load Hook Example:: Pre-select values from the Address Dropdowns</h4>



<p>In case you have enabled <a href="https://agilestorelocator.com/wiki/drop-down-menus-address/">address dropdowns</a> and you want to pre-select a country and it&#8217;s state, you can use the following code.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">/**
   * [asl_event_hook Pre-select the Address dropdown values]
   * @param  {[type]} _event [description]
   * @return {[type]}        [description]
   */
  function asl_event_hook(_event) {
    
    if(_event.type == &#039;load&#039;) {
      
      (function() {

        //  Select Country US by default on the load
        var select_country  = &quot;United States&quot;;
        this.$select = jQuery(&#039;#sl-addr-ddl-country&#039;);
        this.$select.multiselect(&#039;select&#039;, select_country).multiselect(&#039;refresh&#039;);
        asl_view._panel.address_selected.call(this);

        //  Select State CA by default on the load
        var select_state  = &quot;CA&quot;;
        this.$select = jQuery(&#039;#sl-addr-ddl-state&#039;);
        this.$select.multiselect(&#039;select&#039;, select_state).multiselect(&#039;refresh&#039;);
        asl_view._panel.address_selected.call(this);

      })();
    }
  }</code></pre>



<h4 class="wp-block-heading" id="h-js-set-limit-example-apply-limit-on-when-a-search-is-performed">JS Set Limit Example:: Apply limit on when a search is performed</h4>



<p>You can set a limit ONLY when a search is applied, and remove it on the clear search.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
  /**
   * [asl_event_hook Example of before search you can set a limit and remove it on the clear event]
   * @param  {[type]} _event [description]
   * @return {[type]}        [description]
   */
  function asl_event_hook(_event) {

    if(_event.type == &#039;before_search&#039;) {
      
      asl_configuration.stores_limit = 10;
    }
    else if(_event.type == &#039;beforeclear&#039;) {

      asl_configuration.stores_limit = null;
    }
  }
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading" id="h-query-url-parameter-change-the-query-parameter-of-the-state">Query URL Parameter:: Change the Query Parameter of the State</h4>



<p>With the code value, the query parameter for <code class="" data-line="">select-state</code> will change based on the state dropdown selection.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
  
  // Function to update the query string without reloading the page
  function updateQueryStringParameter(key, value) {
      var uri = window.location.href;
      var re = new RegExp(&quot;([?&amp;])&quot; + key + &quot;=.*?(&amp;|$)&quot;, &quot;i&quot;);
      var separator = uri.indexOf(&#039;?&#039;) !== -1 ? &quot;&amp;&quot; : &quot;?&quot;;
      if (uri.match(re)) {
          window.history.replaceState(null, null, uri.replace(re, &#039;$1&#039; + key + &quot;=&quot; + value + &#039;$2&#039;));
      } else {
          window.history.replaceState(null, null, uri + separator + key + &quot;=&quot; + value);
      }
  }

  /**
   * [asl_event_hook Example of changing the parameter via dropdown value]
   * @param  {[type]} _event [description]
   * @return {[type]}        [description]
   */
  function asl_event_hook(_event) {

    if(_event.type == &#039;addr_ddl_event&#039; &amp;&amp; _event.data.type == &#039;state&#039;) {
      updateQueryStringParameter(&#039;select-state&#039;, _event.data.value);
    }
  }
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading">Clear Primary Search on Selection of Address Dropdown</h4>



<p>This code will clear the primary search when the address dropdown option is selected.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">function asl_event_hook(_event) {
    
    if(_event.type == &#039;addr_ddl_event&#039; &amp;&amp; asl_view.dest_coords) {
      asl_view._cont.find(&#039;.asl-clear-btn&#039;).trigger(&#039;click&#039;);
    } 
}</code></pre>



<h4 class="wp-block-heading" id="h-implementing-deep-linking-via-hash">Implementing Deep Linking via Hash</h4>



<p>As Agile Store Locator supports the deep link for the store via the hash value of the store ID, the following snippet can be used to implement it when the store is clicked.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
  function asl_event_hook(_event) {
     
    if(_event.type == &#039;select&#039;) {
      window.location.hash = &#039;#&#039; + _event.data.id;
    }
  }
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading" id="h-show-an-elementor-popup-on-the-event-of-no-stores-found">Show an Elementor Popup on the Event of &#8220;No Stores Found&#8221;</h4>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
  function asl_event_hook(_event) {
     
    if(_event.type == &#039;no_stores&#039;) {
      if (typeof elementorProFrontend !== &#039;undefined&#039; &amp;&amp; elementorProFrontend.modules.popup) {
        elementorProFrontend.modules.popup.showPopup({ id: &#039;id-of-my-popup&#039; });
      } 
    }
  }
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading" id="h-custom-button-events-in-the-listing">Custom Button Events in the Listing</h4>



<p>This event can be added by just adding a CSS Class  <code class="" data-line="">sl-btn-custom</code> to any button in the listing.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="441" src="https://agilestorelocator.com/wp-content/uploads/2024/06/custom-button-event-1024x441.png" alt="Custom Button Event" class="wp-image-3622" title="How to Apply Javascript Hooks 10" srcset="https://agilestorelocator.com/wp-content/uploads/2024/06/custom-button-event-1024x441.png 1024w, https://agilestorelocator.com/wp-content/uploads/2024/06/custom-button-event-300x129.png 300w, https://agilestorelocator.com/wp-content/uploads/2024/06/custom-button-event-768x331.png 768w, https://agilestorelocator.com/wp-content/uploads/2024/06/custom-button-event-360x155.png 360w, https://agilestorelocator.com/wp-content/uploads/2024/06/custom-button-event-350x151.png 350w, https://agilestorelocator.com/wp-content/uploads/2024/06/custom-button-event-76x33.png 76w, https://agilestorelocator.com/wp-content/uploads/2024/06/custom-button-event.png 1173w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h4 class="wp-block-heading">Show Closest Stores (No Store Found) &#8211; Manipulate Results</h4>



<p>Event type <code class="" data-line="">no_stores_filter</code> can be used to return the list of stores, this event is only fired when no stores are found for the result, and on that stage, the list of stores can be provided by applying your own custom filter, the event is released since version 4.11.6.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
  function asl_event_hook(_event) {

  if(_event.type == &#039;no_stores_filter&#039;) {

    // Prepare the list of storse
    var stores_list = Object.assign([], _event.data);

    // Sort the stores by distance
    _event.context.data_.sortDistance(_event.center, stores_list);

    //  Limit the number of stores to 5
    stores_list      = stores_list.slice(0, 5);

    // Update the list of stores
    return stores_list;
  }
};
&lt;/script&gt;</code></pre>



<h4 class="wp-block-heading">Open Accordion Layout Node on the Page Load</h4>



<p>Event type <code class="" data-line="">load</code> when the data is loaded into the store locator, at this stage the event can be utilized to open the node by trigger click on the desired node.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">&lt;script type=&quot;text/javascript&quot;&gt;
  function asl_event_hook(_event) {

  if(_event.type == &#039;load&#039;) {

   jQuery(&#039;.asl-cont #asl-list li[data-id=&quot;18&quot;] &gt; a&#039;).trigger(&#039;click&#039;); // Replace 18 with the ID of the li element
  }
};
&lt;/script&gt;</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Load a Store Directly with a URL?</title>
		<link>https://agilestorelocator.com/wiki/load-a-store-directly-with-a-url/</link>
		
		<dc:creator><![CDATA[Talha Nadeem]]></dc:creator>
		<pubDate>Thu, 29 Jul 2021 07:47:01 +0000</pubDate>
				<category><![CDATA[wiki]]></category>
		<guid isPermaLink="false">https://agilestorelocator.com/?p=1929</guid>

					<description><![CDATA[It is possible to directly load a store page, all it requires is the addition of the store number at the end of the URL. Once the number is added, the user will be taken directly to a specific store page.]]></description>
										<content:encoded><![CDATA[
<p>It is possible to directly load a store page,&nbsp;all it requires is the addition of the store number at the end of the URL. Once the number is added, the user will be taken directly to a specific store page.</p>



<pre class="wp-block-prismatic-blocks"><code class="" data-line="">https://demosite.com/store-locator/#34 </code></pre>



<p>For example, the above URL will highlight the store having ID# 34 in the store locator.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="613" src="https://agilestorelocator.com/wp-content/uploads/2021/07/url-with-store-id-34-1024x613.png" alt="URL with ID #34" class="wp-image-1931" title="Load a Store Directly with a URL? 11" srcset="https://agilestorelocator.com/wp-content/uploads/2021/07/url-with-store-id-34-1024x613.png 1024w, https://agilestorelocator.com/wp-content/uploads/2021/07/url-with-store-id-34-300x180.png 300w, https://agilestorelocator.com/wp-content/uploads/2021/07/url-with-store-id-34-768x460.png 768w, https://agilestorelocator.com/wp-content/uploads/2021/07/url-with-store-id-34-350x210.png 350w, https://agilestorelocator.com/wp-content/uploads/2021/07/url-with-store-id-34-76x46.png 76w, https://agilestorelocator.com/wp-content/uploads/2021/07/url-with-store-id-34.png 1159w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption>URL with ID #34</figcaption></figure>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to get Store Object via PHP?</title>
		<link>https://agilestorelocator.com/wiki/how-to-get-store-object-via-php/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 29 Nov 2022 10:48:49 +0000</pubDate>
				<category><![CDATA[wiki]]></category>
		<guid isPermaLink="false">https://agilestorelocator.com/?p=2890</guid>

					<description><![CDATA[Store PHP object can be fetched easily with all the details via providing the correct Store ID in the method below, the method can be called anywhere, below we have provided an example to call it through the functions.php file of the theme. The results of the above store are as follows.]]></description>
										<content:encoded><![CDATA[
<p>Store PHP object can be fetched easily with all the details via providing the correct Store ID in the method below, the method can be called anywhere, below we have provided an example to call it through the functions.php file of the theme.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">if(method_exists(&quot;\AgileStoreLocator\Helper&quot;, &#039;get_store&#039;)) {
	
	$a_store = \AgileStoreLocator\Helper::get_store(5);	
}</code></pre>



<p>The results of the above store are as follows.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">stdClass Object
(
    [id] =&gt; 5
    [title] =&gt; Bid-Bon Development
    [description] =&gt; bid bid
    [street] =&gt; 274 Kragga Kamma Road, Lorraine
    [city] =&gt; Port Elizabeth
    [state] =&gt; Eastern Cape
    [postal_code] =&gt; 23452
    [lat] =&gt; -33.96524
    [lng] =&gt; 25.50242
    [phone] =&gt; 041 888 3534
    [fax] =&gt; 
    [email] =&gt; 
    [website] =&gt; 
    [logo_id] =&gt; 1
    [path] =&gt; default.png
    [marker_id] =&gt; 1
    [description_2] =&gt; 
    [open_hours] =&gt; {&quot;mon&quot;:&quot;0&quot;,&quot;tue&quot;:&quot;0&quot;,&quot;wed&quot;:&quot;0&quot;,&quot;thu&quot;:&quot;0&quot;,&quot;fri&quot;:&quot;0&quot;,&quot;sat&quot;:&quot;0&quot;,&quot;sun&quot;:&quot;0&quot;}
    [ordr] =&gt; 0
    [brand] =&gt; 1
    [special] =&gt; 
    [custom] =&gt; []
    [slug] =&gt; bid-bon-development-port-elizabeth
)</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Access Stores Programmatically</title>
		<link>https://agilestorelocator.com/wiki/access-stores-programmatically/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Tue, 30 May 2023 12:20:17 +0000</pubDate>
				<category><![CDATA[wiki]]></category>
		<guid isPermaLink="false">https://agilestorelocator.com/?p=3066</guid>

					<description><![CDATA[Agile Store Locator provides support for programmatically retrieving stores using PHP. To obtain the stores, you can utilize the following method: You can pass various parameters in the $clauses array to filter the store values. The available parameters include: By customizing these parameters in the $clauses array, you can retrieve the desired store information programmatically. ... <br><a href="https://agilestorelocator.com/wiki/access-stores-programmatically/" class="text-muted readmore">Read More <i data-feather="chevron-right" class="fea icon-sm"></i></a>]]></description>
										<content:encoded><![CDATA[
<p>Agile Store Locator provides support for programmatically retrieving stores using PHP. To obtain the stores, you can utilize the following method:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">$clauses = [];

$limit = 100;
$offset = 0;

\AgileStoreLocator\Model\Store::get_stores($clauses, $limit, $offset);</code></pre>



<p>You can pass various parameters in the <code class="" data-line="">$clauses</code> array to filter the store values. The available parameters include:</p>



<ul class="wp-block-list">
<li><code class="" data-line="">title</code>: Filter by store title.</li>



<li><code class="" data-line="">description</code>: Filter by store description.</li>



<li><code class="" data-line="">street</code>: Filter by store street address.</li>



<li><code class="" data-line="">city</code>: Filter by store city.</li>



<li><code class="" data-line="">state</code>: Filter by store state.</li>



<li><code class="" data-line="">postal_code</code>: Filter by store postal code.</li>



<li><code class="" data-line="">phone</code>: Filter by store phone number.</li>



<li><code class="" data-line="">fax</code>: Filter by store fax number.</li>



<li><code class="" data-line="">email</code>: Filter by store email.</li>



<li><code class="" data-line="">is_disabled</code>: Filter by disabled store (since version 5.1.4).</li>
</ul>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">$clauses = [&#039;city&#039; =&gt; &#039;NY&#039;];

$limit = 100;
$offset = 0;

\AgileStoreLocator\Model\Store::get_stores($clauses, $limit, $offset);</code></pre>



<p>By customizing these parameters in the <code class="" data-line="">$clauses</code> array, you can retrieve the desired store information programmatically.</p>



<h3 class="wp-block-heading" id="h-create-cards-without-php">Create Cards without PHP</h3>



<p>If you prefer to avoid using PHP, Agile Store Locator also provides store cards that can be displayed using the <code class="" data-line="">[ASL_CARDS]</code> shortcode. You can pass parameters to customize the displayed stores in a similar manner, you can follow the <a href="https://agilestorelocator.com/wiki/stores-cards/">store cards documentation</a>.</p>



<h3 class="wp-block-heading" id="h-create-a-new-store-programatically">Create a New Store Programatically</h3>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">//	Create a new store programatically
if(method_exists(&quot;\AgileStoreLocator\Admin\Store&quot;, &#039;add_new_store&#039;)) {

	$store_data = [
		&quot;title&quot; =&gt; &quot;Bid-Bon Development&quot;,
		&quot;description&quot; =&gt; &quot;bid bid&quot;,
		&quot;street&quot; =&gt; &quot;274 Kragga Kamma Road, Lorraine&quot;,
		&quot;city&quot; =&gt; &quot;Port Elizabeth&quot;,
		&quot;state&quot; =&gt; &quot;Eastern Cape&quot;,
		&quot;postal_code&quot; =&gt; &quot;23452&quot;,
		//&quot;lat&quot; =&gt; &quot;-33.96524&quot;,
		//&quot;lng&quot; =&gt; &quot;25.50242&quot;,
		&quot;phone&quot; =&gt; &quot;041 888 3534&quot;,
	];


	//	Todo, change it
	$have_coordinates = false;
    
    // Add Business Hours (JSON accepted)
    $store_data[&#039;open_hours&#039;] = &#039;{&quot;mon&quot;:[&quot;09:30 AM - 06:30 PM&quot;],&quot;tue&quot;:[&quot;09:30 AM - 06:30 PM&quot;],&quot;wed&quot;:[&quot;09:30 AM - 06:30 PM&quot;],&quot;thu&quot;:[&quot;09:30 AM - 06:30 PM&quot;],&quot;fri&quot;:[&quot;09:30 AM - 06:30 PM&quot;],&quot;sat&quot;:&quot;0&quot;,&quot;sun&quot;:&quot;0&quot;}&#039;;    

	//	I don&#039;t have coordinates :( Let&#039;s fetch it
	if(!$have_coordinates) {

		$google_server_key = \AgileStoreLocator\Helper::get_configs(&#039;server_key&#039;);

		//	1- Get the Coordinates for the provided zipcode
		$coordinates   		= \AgileStoreLocator\Helper::getCoordinates($store_data[&#039;street&#039;], $store_data[&#039;city&#039;], $store_data[&#039;state&#039;], $store_data[&#039;postal_code&#039;], $store_data[&#039;country&#039;], $google_server_key);

		//	Found coordinates?
		if(!empty($coordinates)) {

				$store_data[&#039;lat&#039;] = $coordinates[&#039;lat&#039;];
				$store_data[&#039;lng&#039;] = $coordinates[&#039;lng&#039;];
		}
	}

	//  Add it to request[&#039;data&#039;]
	$_REQUEST[&#039;data&#039;] = $store_data;
    
    // Custom Fields
	$_REQUEST[&#039;asl-custom&#039;] = [&#039;field_name_1&#039; =&gt; &#039;xyz&#039;, &#039;field_name_2&#039; =&gt; &#039;abc&#039;];

	//	Create an instance
	$store_inst = new \AgileStoreLocator\Admin\Store();
	
	// Must be returned as object, else it will die
	$store_inst-&gt;as_object = true;

	//	Create Store
	$response = $store_inst-&gt;add_new_store();


	echo &#039;&lt;pre&gt;&#039;;
	print_r($response);
	echo &#039;/&lt;pre&gt;&#039;;
	die;
}</code></pre>



<h3 class="wp-block-heading" id="h-access-all-categories">Access All Categories</h3>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">
if(method_exists(&quot;\AgileStoreLocator\Model\Category&quot;, &#039;get_categories&#039;)) {

	$lang 			= &#039;&#039;; // Keep empty for default

	//	Get the Stores Categories
	$categories = \AgileStoreLocator\Model\Category::get_categories($lang);
}</code></pre>



<p>To access them in parent and child hierarchy.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">if(method_exists(&quot;\AgileStoreLocator\Model\Category&quot;, &#039;get_categories&#039;)) {

	$lang 			= &#039;&#039;; // Keep empty for default

	//	Get the Stores Categories
	$categories = \AgileStoreLocator\Model\Category::get_app_categories($lang);
}</code></pre>



<h3 class="wp-block-heading">Get All the Store Titles</h3>



<p>The code below can be used to get the titles of all the stores, or any other attributes.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">// Check if the &#039;get_stores&#039; method exists in the Store model
if (method_exists(&quot;\AgileStoreLocator\Model\Store&quot;, &#039;get_stores&#039;)) {

    // Retrieve all stores using the get_stores method
    $stores = \AgileStoreLocator\Model\Store::get_stores();

    // Extract the &#039;title&#039; column from the stores array and remove duplicates
    $store_titles = array_unique(array_column($stores, &#039;title&#039;));

    // Initialize the dropdown HTML with a select element for store titles
    $store_dropdown = &#039;&lt;select id=&quot;asl-stores-title&quot; name=&quot;store-titles&quot;&gt;&#039;;

    // Loop through each unique store title and create an option element
    foreach ($store_titles as $title) {
        $store_dropdown .= &#039;&lt;option value=&quot;&#039; . esc_attr($title) . &#039;&quot;&gt;&#039; . esc_html($title) . &#039;&lt;/option&gt;&#039;;
    }

    // Close the select element
    $store_dropdown .= &#039;&lt;/select&gt;&#039;;

    // Output the complete dropdown
    echo $store_dropdown . &#039;&lt;br&gt;&#039;;
} 
else {
    // Fallback message if the get_stores method does not exist
    echo &#039;Store data could not be loaded.&#039;;
}</code></pre>



<h3 class="wp-block-heading">Programmatically Find the Nearest Store</h3>



<p>Agile Store Locator provides a built-in helper method that lets you fetch the closest store(s) to a given latitude and longitude directly from PHP. This is useful for custom integrations such as checkout logic, location-based routing, third-party APIs, or any workflow where you need to determine the nearest store programmatically.</p>



<h4 class="wp-block-heading">Parameters</h4>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>$origLat</strong></td><td>Origin latitude.</td></tr><tr><td><strong>$origLon</strong></td><td>Origin longitude.</td></tr><tr><td><strong>$dist</strong></td><td>Maximum search radius <em>in miles</em>.</td></tr><tr><td><strong>$clauses</strong></td><td><em>(Optional)</em> Associative array for additional filters, such as categories, custom fields, or store metadata.<br>Example: <code class="" data-line="">[&#039;categories&#039; =&gt; 12]</code>.</td></tr><tr><td><strong>$limit</strong></td><td>Number of stores to return. Default is <code class="" data-line="">1</code> (the closest store). If set higher, the method returns an array of store objects ordered by distance.</td></tr></tbody></table></figure>



<h4 class="wp-block-heading">Example Usage</h4>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">$lat    = 40.7128;
$lng    = -74.0060;
$radius = 25; // miles

if ( class_exists(&#039;\AgileStoreLocator\Helper&#039;) ) {

    $filters = [&#039;categories&#039; =&gt; 5];

    $closest = \AgileStoreLocator\Helper::get_closest_store($lat, $lng, $radius, $filters);

    if ($closest) {
        echo &#039;Nearest store: &#039; . $closest-&gt;title . &#039; (&#039; . $closest-&gt;distance . &#039; miles away)&#039;;
    }
}</code></pre>



<h4 class="wp-block-heading">Getting Multiple Nearby Stores</h4>



<p>If you need more than one result, simply increase the <code class="" data-line="">$limit</code>:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">if ( class_exists(&#039;\AgileStoreLocator\Helper&#039;) ) {

    $stores = \AgileStoreLocator\Helper::get_closest_store($lat, $lng, $radius, [], 5);

    foreach ($stores as $store) {
        echo $store-&gt;title . &#039; - &#039; . $store-&gt;distance . &quot; miles\n&quot;;
    }
}
</code></pre>



<p>The returned list will be sorted automatically from nearest to farthest.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Show Store Detail as Meta Tag</title>
		<link>https://agilestorelocator.com/wiki/show-store-detail-as-meta-tag/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 20 Feb 2023 11:20:25 +0000</pubDate>
				<category><![CDATA[wiki]]></category>
		<guid isPermaLink="false">https://agilestorelocator.com/?p=2973</guid>

					<description><![CDATA[In case you want to display the store-related information such as store title, or store address attributes such as city state or any custom field, you can add the following code in your theme functions.php to make it appear. In the above code, we have hard-coded the store detail page ID, in your WordPress instance, ... <br><a href="https://agilestorelocator.com/wiki/show-store-detail-as-meta-tag/" class="text-muted readmore">Read More <i data-feather="chevron-right" class="fea icon-sm"></i></a>]]></description>
										<content:encoded><![CDATA[
<p>In case you want to display the store-related information such as store title, or store address attributes such as city state or any custom field, you can add the following code in your theme functions.php to make it appear.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-php" data-line="">/**
* 
* Add custom Meta Tag to header. 
*/
function asl_header_meta_callback() {

	global $post;


	//	Page ID of the Store Detail
	if($post &amp;&amp; $post-&gt;ID == &#039;2459&#039; &amp;&amp; defined(&#039;ASL_PLUGIN&#039;)) {

		//	Get the Store title
		$store_title = do_shortcode(&#039;[ASL_STORE field=&quot;title&quot;]&#039;);

		//	Have Store title?
		if($store_title) {

			$store_city = do_shortcode(&#039;[ASL_STORE field=&quot;city&quot;]&#039;);

			echo &#039;&lt;meta name=&quot;store-detail&quot; content=&quot;&#039;.esc_attr($store_title).&#039; in &#039;.esc_attr($store_city).&#039;&quot;&gt;&#039;;
		}
	}
    
}

add_action( &#039;wp_head&#039;, &#039;asl_header_meta_callback&#039; );</code></pre>



<p>In the above code, we have hard-coded the store detail page ID, in your WordPress instance, it will be different of course, so make sure to change it, we have utilized the <a href="https://agilestorelocator.com/wiki/render-store-fields-data/">store field render</a> methods.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Load a Parameter with a Query String</title>
		<link>https://agilestorelocator.com/wiki/load-parameter-with-query-string/</link>
		
		<dc:creator><![CDATA[Talha Nadeem]]></dc:creator>
		<pubDate>Fri, 30 Jul 2021 11:48:35 +0000</pubDate>
				<category><![CDATA[wiki]]></category>
		<guid isPermaLink="false">https://agilestorelocator.com/?p=1950</guid>

					<description><![CDATA[Agile Store Locator makes it possible for users to load a parameter using a query string. Thereby, directing their customers to the store locator with a specific parameter preselected. ]]></description>
										<content:encoded><![CDATA[
<p>Agile Store Locator makes it possible for users to load a parameter using a query string. Thereby, directing their customers to the store locator with a specific parameter preselected. For example, there could be a link that takes your customer to the store locator with the address “ California” pre-selected.&nbsp;</p>



<p>While it may seem like a small detail. Eventually, customers will appreciate how much time and effort they are saved&nbsp; (no matter how small) by directly loading the store locator with a certain parameter.</p>



<h4 class="wp-block-heading"><strong>How Does it Work?</strong></h4>



<p>A query string (added) at the end of the store locator URL takes the customer to the store.</p>



<p>Furthermore, the Parameters to pre-select include:</p>



<ol class="wp-block-list">
<li>Category &#8211; “category”</li>



<li>Brand &#8211; “brand”</li>



<li>Address -”addr”</li>
</ol>



<p>The query string added at the end of the URL is: “?sl-category=x”</p>



<p>Where “x” represents the parameter ID ( the parameter ID can be alphabetic or numeric; depending on the parameter selected). In addition, the term “category” can be replaced with “brand” or “addr”.</p>



<p>For example, if a user wants to direct a customer to the store locator with “California” pre-selected as the address then the following query string is added at the end of the URL:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">https://your-site.com/store-locator/?sl-addr=california</code></pre>



<p>Similarly, for the categories, it will be like this, where 4  is the category to be selected on the load, multiple categories can also be passed comma separated.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">https://your-site.com/store-locator/?sl-category=4</code></pre>



<p>For the brand, you need to provide the brand ID as the query parameter to pre-select it.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">https://your-site.com/store-locator/?sl-brand=5</code></pre>



<p>For the specialty, you have to provide the specialty id as the query parameter to pre-select it.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">https://your-site.com/store-locator/?sl-special=5</code></pre>



<p>An example of sl-addr,  the overall URL will look like this:</p>



<p><a href="http://demosite.com/index.php/store-locator/?sl-addr=california" target="_blank" rel="noopener">http://demosite.com/index.php/store-locator/?sl-addr=california</a></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="593" src="https://agilestorelocator.com/wp-content/uploads/2021/07/address-query-string-1024x593.png" alt="Store Locator with Pre-Selected Parameter" class="wp-image-1951" title="Load a Parameter with a Query String 12" srcset="https://agilestorelocator.com/wp-content/uploads/2021/07/address-query-string-1024x593.png 1024w, https://agilestorelocator.com/wp-content/uploads/2021/07/address-query-string-300x174.png 300w, https://agilestorelocator.com/wp-content/uploads/2021/07/address-query-string-768x445.png 768w, https://agilestorelocator.com/wp-content/uploads/2021/07/address-query-string-350x203.png 350w, https://agilestorelocator.com/wp-content/uploads/2021/07/address-query-string-76x44.png 76w, https://agilestorelocator.com/wp-content/uploads/2021/07/address-query-string.png 1089w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption"><em>Store Locator with Pre-Selected Parameter</em></figcaption></figure>



<p>If you are looking to filter through address-related fields such as city, state, postal_code, you can refer to the document about <a href="https://agilestorelocator.com/wiki/filter-address-using-query-parameter-or-shortcode/">filtering data through the shortcode attributes</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Variables for the Template Customization</title>
		<link>https://agilestorelocator.com/wiki/list-of-variables-store-locator/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sat, 15 May 2021 16:35:45 +0000</pubDate>
				<category><![CDATA[wiki]]></category>
		<guid isPermaLink="false">https://agilestorelocator.com/?p=1800</guid>

					<description><![CDATA[Agile Store Locator supports customization of its list and the info-window that appear once you click on the marker.]]></description>
										<content:encoded><![CDATA[
<p> Agile Store Locator supports customization of its list and the info windows that appear once you click on a marker. In addition, we have a video guide about how you can customize the Store Locator templates. </p>



<p>Furthermore,  you might require the variables&#8217; names that can be used in the customization. We have provided below a list of variables that can be inserted into the template.<code class="" data-line=""> </code></p>



<pre class="wp-block-prismatic-blocks"><code class="language-css" data-line="">{{:id}} {{:title}} {{:address}} {{:city}} {{:state}} {{:country}} {{:postal_code}} {{:street}} {{:open_hours}} {{:description}} {{:description_2}}
{{:dist_str}} // For the distance  
{{:c_names}}  // For the Categories 
{{:str_brand}}  // For the Brands 
{{:str_special}}  // For the Specialities </code></pre>



<p> The custom fields that are created by the &#8220;Custom Field Manager&#8221; can be used in the same way as the default variables. For example, a field called facebook_url will appear as the following:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-markup" data-line=""> {{:facebook_url}}</code></pre>



<h4 class="wp-block-heading">Example 1: How to Add Store Open Days to the Store List</h4>



<p>Users of Agile Store Locator can add the store opening days to the store list by following the below steps:</p>



<ol class="wp-block-list"><li>Go to &#8220;ASL Setting&#8221;, and head over to the &#8220;Customizer&#8221; tab</li><li>Select the template you are using from the &#8220;Template&#8221; drop-down menu</li><li>Select &#8220;list&#8221; from the &#8220;Sections&#8221; drop-down menu</li><li>Click on &#8220;Load Template&#8221;</li><li>Insert the below code into the template editor, and click on &#8220;Save Setting&#8221;</li></ol>



<pre class="wp-block-prismatic-blocks"><code class="language-markup" data-line=""> {{if days_str}}
&lt;li class=&quot;sl-days&quot;&gt;
 &lt;i class=&quot;icon-calendar&quot;&gt;&lt;/i&gt;
 &lt;span class=&quot;txt-hours&quot;&gt;{{:days_str}}&lt;/span&gt;
&lt;/li&gt;
{{/if}}</code></pre>



<p>Once you add the above code the &#8220;store open days&#8221; (Mon, Tues, Wed, etc.) will be added to the store list.</p>



<div class="wp-block-image"><figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" src="https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-day-list.png" alt="Store Open Days in the Store List" class="wp-image-2428" width="415" height="383" title="Variables for the Template Customization 13" srcset="https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-day-list.png 553w, https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-day-list-300x277.png 300w, https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-day-list-285x263.png 285w, https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-day-list-62x57.png 62w" sizes="auto, (max-width: 415px) 100vw, 415px" /><figcaption>Store Open Days in the Store List</figcaption></figure></div>



<h4 class="wp-block-heading">Example 2: How to Add Store Open Days to the Infobox</h4>



<p>Users of Agile Store Locator can add store opening days to the store infobox by following the below steps:</p>



<ol class="wp-block-list"><li>Go to &#8220;ASL Setting&#8221;, and head over to the &#8220;Customizer&#8221; tab</li><li>Select the template you are using from the &#8220;Template&#8221; drop-down menu</li><li>Select &#8220;infobox&#8221; from the &#8220;Sections&#8221; drop-down menu</li><li>Click on &#8220;Load Template&#8221;</li><li>Insert the below code into the template editor, and click on &#8220;Save Setting&#8221;</li></ol>



<pre class="wp-block-prismatic-blocks"><code class="language-markup" data-line="">{{if open_hours}}
      &lt;div class=&quot;pol-12&quot;&gt;
         &lt;div class=&quot;info-addr-inner&quot;&gt;
            &lt;i class=&quot;icon-clock&quot;&gt;&lt;/i&gt;
            &lt;span class=&quot;txt-hours&quot;&gt;{{:open_hours}}&lt;/span&gt;
         &lt;/div&gt;
      &lt;/div&gt;
      {{/if}}
      {{if days_str}}
      &lt;div class=&quot;pol-12&quot;&gt;
         &lt;div class=&quot;info-addr-inner&quot;&gt;
            &lt;i class=&quot;icon-calendar&quot;&gt;&lt;/i&gt;
            &lt;span class=&quot;txt-hours&quot;&gt;{{:days_str}}&lt;/span&gt;
         &lt;/div&gt;
      &lt;/div&gt;
      {{/if}}</code></pre>



<p>Once you add the above code the &#8220;store open days&#8221; (Mon, Tues, Wed, etc.) will be added to the store infobox.</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="486" height="507" src="https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-days-infobox.png" alt="Store Open Days in the Infobox" class="wp-image-2430" title="Variables for the Template Customization 14" srcset="https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-days-infobox.png 486w, https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-days-infobox-288x300.png 288w, https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-days-infobox-252x263.png 252w, https://agilestorelocator.com/wp-content/uploads/2022/04/store-open-days-infobox-55x57.png 55w" sizes="auto, (max-width: 486px) 100vw, 486px" /><figcaption>Store Open Days in the Infobox</figcaption></figure></div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Render Store Fields Data</title>
		<link>https://agilestorelocator.com/wiki/render-store-fields-data/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Thu, 02 Feb 2023 10:51:56 +0000</pubDate>
				<category><![CDATA[wiki]]></category>
		<guid isPermaLink="false">https://agilestorelocator.com/?p=2947</guid>

					<description><![CDATA[Since version 4.8.20, the store locator has a new attribute that can display a single store data via the shortcode attribute, such as you can display the address or title of any store at some point on the page, through the following shortcode attribute. The above shortcode will only render the address of the store ... <br><a href="https://agilestorelocator.com/wiki/render-store-fields-data/" class="text-muted readmore">Read More <i data-feather="chevron-right" class="fea icon-sm"></i></a>]]></description>
										<content:encoded><![CDATA[
<p>Since version 4.8.20, the store locator has a new attribute that can display a single store data via the shortcode attribute, such as you can display the address or title of any store at some point on the page, through the following shortcode attribute.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">[ASL_STORE sl-store=&quot;6&quot;  field=&quot;address&quot;]</code></pre>



<p>The above shortcode will only render the address of the store having the store ID 6.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">[ASL_STORE sl-store=&quot;7&quot;  field=&quot;title&quot;]</code></pre>



<p>The above shortcode will only render the title of the store having the store ID 7.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">[ASL_STORE field=&quot;title&quot;]</code></pre>



<p>You don&#8217;t need to provide the sl-store attribute in the shortcode if the slug is on the URL of the page.</p>



<h3 class="wp-block-heading">Store Detail Map Only</h3>



<p>To render a map only of the store detail page, specify the store map in the field attribute.</p>



<pre class="wp-block-prismatic-blocks"><code class="language-git" data-line="">[ASL_STORE field=&quot;map&quot;]</code></pre>



<p>Similarly, you can display any default or custom field as well.</p>



<figure class="wp-block-table"><table><tbody><tr><td><strong>Field Name</strong></td><td><strong>Field Description</strong></td></tr><tr><td>id</td><td>ID of the store</td></tr><tr><td>title</td><td>Name of the store</td></tr><tr><td>email</td><td>Email of the store</td></tr><tr><td>phone</td><td>Phone number of the store</td></tr><tr><td>address</td><td>Full address of the store</td></tr><tr><td>city</td><td>City name of the store</td></tr><tr><td>state</td><td>State of the store</td></tr><tr><td>country</td><td>Country name of the store</td></tr><tr><td>open_hours</td><td>Opening hours of the store</td></tr><tr><td>lat</td><td>Latitude value of the store</td></tr><tr><td>lng</td><td>Longitude value of the store</td></tr><tr><td>map</td><td>Render the map of the store detail</td></tr></tbody></table><figcaption class="wp-element-caption">Possible values</figcaption></figure>



<p>Any custom field that is created through the Custom Fields can also be displayed similarly.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
