Store Locator Plugin Guide

Store Locator WordPress Hooks/Filters

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

asl_filter_stores_resultThe purpose of the above filter is to change the dataset of the stores that are thrown to the store locator in JSON format.
asl_filter_locator_attrsTo 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.
asl_filter_locator_wordsIn 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.
asl_filter_search_widget_wordsIn case you want to change or replace any word text of the Search widget can be done via this filter.
asl_parse_csvThis filter can be used to manipulate the data before it is imported via the CSV importer tool.
asl_woocommerce_store_settingsThis filter is being used in the Multi-Store Addons for WooCommerce before the Store data is saved through the form.
asl_filter_store_detailThis filter will be fired when the store detail widget is being used on some page.
asl_filter_store_formThis filter will be fired during the rendering of the Store Registration form, you can change the configuration of the form using it.
asl_filter_locator_configThis filter will be fired before the rendering of the Store Locator, you can tweak the configs using it.
asl_filter_pre_register_storeThis 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)
asl_action_store_registeredThis action will be fired after the store registration form is saved, it provides the ID of the saved store, since version (4.9.15)
asl_before_stores_importAn 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)
Filter Hooks Table

How to use the above filters?

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

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

 * [asl_filter_locator_method description]
 * @param  [type] $attrs [description]
 * @return [type]        [description]
function asl_filter_locator_method($attrs) {

	global $wpdb;

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

	if($q_category) {

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

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

			$attrs['select_category'] = $locator_category[0]->id;

	return $attrs;

add_filter('asl_filter_locator_attrs', 'asl_filter_locator_method');

Apply your own CSS file for the Search Widget

 * [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
  //	Add your customized search file
  wp_enqueue_style('asl-search-widget',  get_template_directory_uri().'/asl_search-updated.css', array(), '4.9.12', 'all' );

	return $words;

add_filter('asl_filter_search_widget_words', 'asl_filter_search_widget_words_method');

Store Results Filter to Manipulate or Change the Store Data

 * [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->agent = 'John Doe';

  return $all_stores;

add_filter('asl_filter_stores_result', 'asl_add_additional_column');

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

 * [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

	//	Add the Store 2

  return $my_stores;

add_filter('asl_filter_stores_result', 'asl_stores_custom_data');

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

// Delete all my stores before the import of new files, Tested with version 4.9.15
add_action('asl_before_stores_import', function() {

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

	//	Yes, delete everything, CAN'T be restored!