Support » Plugins and Hacks » Store Locator Plus for WordPress » [Plugin: Google Maps via Store Locator Plus] Adding extra fields in Locations

[Plugin: Google Maps via Store Locator Plus] Adding extra fields in Locations

  • Hi,
    please i need an help.
    i’m triyng to add some extra fieds in Locations made by simple input text and checkboxes.

    I now that is not suggested to change core files, but i need to personalized SLP.

    Managed to modify the files:
    and of course adding my desired field in MySql Table store_locator

    i’ve inserted my own text input fields with no problem, and i’m ablle to add and edit data.

    My problems comes with checkboxes as ‘0’ and ‘1’ values. No problem to INSERT or UPDATE db values when i check the box to write ‘1’ in db. But if i uncheck a box in edit mode, i cannot write ‘0’ in db, so i cannot uncheck value.

    i tryed with something like:

    $query = sprintf("UPDATE " . $wpdb->prefix ."store_locator " . "SET sl_r_accinf = '0' WHERE sl_id NOT IN ()";

    but nothig happen.
    Can you help me solving this MY problem?
    Thanks in advance.


Viewing 1 replies (of 1 total)
  • Plugin Author Store Locator Plus


    I suggest you use the hooks & filters that do just this, available since version 3.5. This way you can create your own plugin in a separate directory that will not be overwritten when upgrading and still interacts with SLP. Enhanced Search is a small version of a plugin that does just this. Tagalong is a more extensive plugin that uses a lot of the tricks you will want to mimic. It should be out later this month.


    Store the data in a serialized named array in sl_option_value (a new field since 3.5) using the data filter and setting the sl_option_value similar to this:

    // Manage Locations Interface
                        array($this, 'add_categories_column')
                        array($this, 'render_categories_column'),
             * Attach our category data to the update string.
             * Put it in the sl_option_value field as a seralized string.
             * @param string $sqlSetStr - the original SQL set syntax
             * @return string - the modified SQL set syntax
            function location_update_data($sqlSetStr,$locationID) {
                if (isset($_POST['tax_input'])) {
                    $originalOptionArray = slp_deserialize_to_array($_POST['option_value-'.$locationID]);
                    $newOptionArray =
                                        'store_categories' => $_POST['tax_input']
                $sqlSetStr = preg_replace("/, sl_option_value='(.*?)'/",'',$sqlSetStr);
                return $sqlSetStr.", sl_option_value='".maybe_serialize($newOptionArray)."'" ;
             * Add the category editor/selector on the manage/edit location form.
             * @param string $theForm - the original HTML form for the manage locations edit (right side)
             * @return string - the modified HTML form
            function location_edit_category($theForm) {
                                'checked_ontop' => false,
                                'taxonomy' => 'stores',
                $checkList = ob_get_contents();
                $theForm .= '<div id="slp_tagalong_categories"><strong>Tagalong</strong>'.
                        $checkList .
                return $theForm;
             * Add the categories column to the manage locations table.
             * @param named array $currentCols - column name + column label for existing items
             * @return named array - column name + column labels, extended with our categories data
            function add_categories_column($currentCols) {
                return array_merge($currentCols,
                            'sl_option_value'       => __('Categories'        ,SLPLUS_PREFIX)
             * Render the categories column in the view locations table.
             * @param string $theData  - the option_value field data from the database
             * @param string $theField - the name of the field from the database (should be sl_option_value)
             * @param string $theLabel - the column label for this column (should be 'Categories')
             * @return type
            function render_categories_column($theData,$theField,$theLabel) {
                if (
                    ($theField === 'sl_option_value') &&
                    ($theLabel === __('Categories'        ,SLPLUS_PREFIX))
                   ) {
                    // No Category selected
                    if ($theData != '') {
                        $OptionArray = slp_deserialize_to_array($theData);
                        if (isset($OptionArray['store_categories']['stores'])){
                            $theData = '';
                            foreach ($OptionArray['store_categories']['stores'] as $optVal) {
                                $theCat = get_term($optVal,'stores');
                                $tagalongData = get_option(SLPLUS_PREFIX.'-TAGALONG-category_'.$theCat->term_id);
                                $theData .= '<div class="tagalong_entry">'.$theCat->name;
                                if (isset($tagalongData['map-marker']) && ($tagalongData['map-marker']!='')) {
                                    $theData .=
                                        '<img src="'.$tagalongData['map-marker'].'" '.
                                            'id="slp_map_marker_'.$theCat->slug.'" '.
                                            'class="slp_map_marker" '.
                                            'alt="'.$theCat->slug.'" '.
                                $theData .= '</div>';
                                //$theData .= '<pre>'.print_r($theCat,true).'</pre>';
                                //$theData .= '<pre>'.print_r($tagalongData,true).'</pre>';
                return $theData;
Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Google Maps via Store Locator Plus] Adding extra fields in Locations’ is closed to new replies.
Skip to toolbar