Forum Replies Created

Viewing 15 replies - 16 through 30 (of 153 total)
  • Hi Tijmen. Thanks for your reply!

    It works ok!

    Now, I want to declare another store meta but I get an error. My code looks like this:

    add_filter( 'wpsl_store_meta', 'custom_store_meta', 10, 2 );
    function custom_store_meta( $store_meta, $store_id ) {
        $terms = wp_get_post_terms( $store_id, 'wpsl_store_category' );
        $store_meta['terms'] = '';
        store_meta['icons'] = '';
        if ( !is_wp_error( $terms ) ) {
             if (function_exists('z_taxonomy_image')) {
    			$store_meta['terms'] = z_taxonomy_image_url($terms[0]->term_id);
    			$store_meta['icons'] = z_taxonomy_image($terms[0]->term_id);
    		}
    	}
        return $store_meta;
    }
    
    function custom_frontend_meta_fields( $store_fields ) {
        $store_fields['wpsl_terms'] = array(
            'name' => 'terms'
        );
        $store_fields['wpsl_icons'] = array(
            'name' => 'icons'
        );
        return $store_fields;
    }

    And in my custom listing template I put this line:

    $listing_template .= "\t\t" . '<%= icons %>' . "\r\n";

    I get the error:
    ReferenceError: icons is not defined

    What I’m doing wrong?

    Thanks in advance.

    I can’t figure out how to arribe to question 1 (I tried $location_terms = $term[0]->term_id / $store_meta[‘terms’] = $location_terms[0] with no luck) but… I get different custom markers for each location!

    Here are the steps:
    1) Install “Category Images” plugin and assign images to each store category. You can use svg files (better for rendering in mobile devices)
    2) Put this piece of code into your functions.php file:

    add_filter( 'wpsl_store_meta', 'custom_store_meta', 10, 2 );
    function custom_store_meta( $store_meta, $store_id ) {
        $terms = wp_get_post_terms( $store_id, 'wpsl_store_category' );
        $store_meta['terms'] = '';
        if ( !is_wp_error( $terms ) ) {
    		if ( count( $terms ) > 1 ) {
                $location_terms = array();
                foreach ( $terms as $term ) {
                    if (function_exists('z_taxonomy_image')) {
    					$location_terms = z_taxonomy_image_url($term->term_id);
    				}
                }
                $store_meta['terms'] = $location_terms;
            } else {
    			if (function_exists('z_taxonomy_image')) {
                	$store_meta['terms'] = z_taxonomy_image_url($terms[0]->term_id);
    			}
            }
        }
        return $store_meta;
    }

    3) Modify the addMarker function into wpsl-gmap.js
    Remove this:

    if ( storeId === 0 ) {
    		infoWindowData = {
    			store: wpslLabels.startPoint
    		};
    
    		markerPath = wpslSettings.path + "img/markers/" + wpslSettings.startMarker;
    	} else {
    		markerPath = wpslSettings.path + "img/markers/" + wpslSettings.storeMarker;
    	}
    	mapIcon = {
    		url: markerPath,
    		scaledSize: new google.maps.Size( 24,35 ), //retina format
    		origin: new google.maps.Point( 0,0 ),
    		anchor: new google.maps.Point( 12,35 )
    	};

    Put this:

    if ( storeId === 0 ) {
    		infoWindowData = {
    			store: wpslLabels.startPoint
    		};
    		markerPath = wpslSettings.path + "img/markers/" + wpslSettings.startMarker;
    
    		mapIcon = {
    			url: markerPath,
    			scaledSize: new google.maps.Size( 24,35 ),
    			origin: new google.maps.Point( 0,0 ),
    			anchor: new google.maps.Point( 12,35 )
    		};
    	} else {
    		markerPath = infoWindowData.terms;
    
    		mapIcon = {
    			url: markerPath,
    			scaledSize: new google.maps.Size( 48,48 ),
    			origin: new google.maps.Point( 0,0 ),
    			anchor: new google.maps.Point( 12,35 )
    		};
    	}

    That’s all!!! I hope it helps.

    I’m having same problem! Can anyone guide me in how to hook the add_meta_box() call?

    Thanks in advance.

    Great! It works!

    Just 2 more questions

    1) How can I get only one category name (the first one) instead of all?
    2) How can I send the value to the function addMarker in wpsl-gmap.js?

    Thanks!

    I don’t know what I’m doing wrong 🙁
    I’m getting this error again:
    ReferenceError: terms is not defined
    http://grupopropeller.com/web2015/wp-includes/js/underscore.min.js?ver=1.6.0 line 5 > Function
    Line 4

    Well… this is weird. I got it working and I figured out the problem you report. But now, it isn’t working anymore. On first load, markers and list aren’t displayed. Only start point marker.
    If I make a search, everything is displayed ok.

    I get this:
    TypeError: n is null
    http://grupopropeller.com/web2015/wp-includes/js/underscore.min.js?ver=1.6.0
    Line 5

    The code in my functions.php looks like this:

    add_filter( 'wpsl_store_meta', 'custom_store_meta', 10, 2 );
    function custom_store_meta( $store_meta, $store_id ) {
    
        $terms = wp_get_post_terms( $store_id, 'wpsl_store_category' );
    
        $store_meta['terms'] = '';
    
        if ( !is_wp_error( $terms ) ) {
            if ( count( $terms ) > 1 ) {
                $location_terms = array();
    
                foreach ( $terms as $term ) {
                    $location_terms[] = $term->slug;
                }
    
                $store_meta['terms'] = implode( ', ', $location_terms );
            } else {
                $store_meta['terms'] = $terms[0]->slug;
            }
        }
    
        return $store_meta;
    }
    
    add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' );
    function custom_frontend_meta_fields( $store_fields ) {
        $store_fields['wpsl_terms'] = array(
            'name' => 'terms'
        );
        return $store_fields;
    }
    
    add_filter( 'wpsl_listing_template', 'custom_listing_template' );
    function custom_listing_template() {
        global $wpsl_settings;
    	$listing_template = '<li class="<%= terms %>" data-store-id="<%= id %>">' . "\r\n";
    	$listing_template .= "\t\t" . '<div>' . "\r\n";
        $listing_template .= "\t\t\t" . '<p><%= thumb %>' . "\r\n";
        $listing_template .= "\t\t\t\t" . wpsl_store_header_template( 'listing' ) . "\r\n";
    	$listing_template .= "\t\t\t\t" . '<span class="wpsl-street"><%= address %></span>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<% if ( address2 ) { %>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span class="wpsl-street"><%= address2 %></span>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<% } %>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span>' . wpsl_address_format_placeholders() . '</span>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span class="wpsl-country"><%= country %></span>' . "\r\n";
        $listing_template .= "\t\t\t" . '</p>' . "\r\n";
    	$listing_template .= "\t\t" . '</div>' . "\r\n";
        if ( !$wpsl_settings['hide_distance'] ) {
            $listing_template .= "\t\t" . '<%= distance %> ' . esc_html( $wpsl_settings['distance_unit'] ) . '' . "\r\n";
        }
        $listing_template .= "\t\t" . '<%= createDirectionUrl() %>' . "\r\n";
        $listing_template .= "\t" . '</li>' . "\r\n";
        return $listing_template;
    }

    I can’t figure out how to include the terms field in the ajax response.
    I tried:

    add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' );
    function custom_frontend_meta_fields( $store_fields ) {
        $store_fields['wpsl_terms'] = array(
            'name' => 'terms',
            //'type' => 'url'
        );
    
        return $store_fields;
    }

    What I’m doing wrong?

    I will explain you my goal and maybe we can arrive to a better solution.
    I want to display different markers based on categories. I know that this function isn’t developed yet, but I was thinking in a way to hack some solution.
    With a plugin (Categories Images) I was able to add icons to each category. This is the easy part.
    Each store is assigned to only one category.
    So, I was looking for a way to get the url image of the category assigned to each store and send that url to wpsl-gmaps.js. Something like:
    markerPath = categoryIcon
    I guess that first I need to process the terms and get the category image url asigned to each store with php code. I think that something link this will work:

    foreach (get_the_terms($store_id, 'wpsl_store_category') as $catIcons) :
    if (function_exists('z_taxonomy_image')) {
      $categoryIcon = z_taxonomy_image_url($catIcons->term_id);
    }
    endforeach

    I don’t know how to send $categoryIcon to wpsl-gmaps.js
    What do you think?

    I go back to:
    $listing_template = '<li class="<%= terms %>" data-store-id="<%= id %>">';
    Also tried:
    $listing_template = '<li class="<% if ( terms ) { %> <%= terms %> <% } %>" data-store-id="<%= id %>">' . "\r\n";

    But we haven’t luck. Still getting:
    ReferenceError: terms is not defined
    ((__t=( terms ))==null?”:__t)+

    Hi Tijmen. Yes, you are right. If I remove the whole “terms” part, everything goes ok.

    This is the error I get now:
    ReferenceError: terms is not defined
    if ( terms ) {

    Hi Tijmen. I tried your code but it isn’t working for me. Maybe something change in recent plugin versions.

    if ( storeId === 0 ) {
        markerPath = wpslSettings.path + "img/markers/" + wpslSettings.startMarker;
    
        mapIcon = {
            url: markerPath,
            scaledSize: new google.maps.Size( 24,35 ),
            origin: new google.maps.Point( 0,0 ),
            anchor: new google.maps.Point( 12,35 )
        };
    } else {
        markerPath = infoWindowData.thumb;
    
        mapIcon = {
            url: markerPath,
            scaledSize: new google.maps.Size( 32,32 ),
            origin: new google.maps.Point( 0,0 ),
            anchor: new google.maps.Point( 12,35 )
        };
    }

    I get en error like this:
    “NetworkError: 404 Not Found – http://grupopropeller.com/web2015/concesionarios/%3Cimg%20width=%2245%22%20height=%2216%22%20src=%22http:/grupopropeller.com/web2015/wp-content/uploads/logo-header-200×70.png%22%20class=%22wpsl-store-thumb%20wp-post-image%22%20alt=%22AZ%20MARINE%22%20/%3E&#8221;

    Where does the .thumb variable come from? Is in a php file? If so, maybe I can develop a code to fit my needs (display different marker icons based on category)

    Once again, thanks in advance (and sorry for my bad english).

    I came from this post

    This is not working for me. My code into functions.php look like this:

    <?php
    add_filter( 'wpsl_store_meta', 'custom_store_meta', 10, 2 );
    
    function custom_store_meta( $store_meta, $store_id ) {
    
        $terms = wp_get_post_terms( $store_id, 'wpsl_store_category' );
    
        if ( count( $terms ) > 1 ) {
            $location_terms = array();
    
            foreach ( $terms as $term ) {
                $location_terms[] = $term->name;
            }
    
            $store_meta['terms'] = implode( ', ', $location_terms );
        }
    
        return $store_meta;
    }
    add_filter( 'wpsl_listing_template', 'custom_listing_template' );
    
    function custom_listing_template() {
    
        global $wpsl_settings;
    
    	$listing_template = '<li class="<%= terms %>" data-store-id="<%= id %>">' . "\r\n";
    	$listing_template .= "\t\t" . '<div>' . "\r\n";
        $listing_template .= "\t\t\t" . '<p><%= thumb %>' . "\r\n";
        $listing_template .= "\t\t\t\t" . wpsl_store_header_template( 'listing' ) . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span class="wpsl-street"><%= address %></span>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<% if ( address2 ) { %>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span class="wpsl-street"><%= address2 %></span>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<% } %>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span>' . wpsl_address_format_placeholders() . '</span>' . "\r\n";
        $listing_template .= "\t\t\t\t" . '<span class="wpsl-country"><%= country %></span>' . "\r\n";
        $listing_template .= "\t\t\t" . '</p>' . "\r\n";
    	$listing_template .= "\t\t" . '</div>' . "\r\n";
    
        if ( !$wpsl_settings['hide_distance'] ) {
            $listing_template .= "\t\t" . '<%= distance %> ' . esc_html( $wpsl_settings['distance_unit'] ) . '' . "\r\n";
        }
    
        $listing_template .= "\t\t" . '<%= createDirectionUrl() %>' . "\r\n";
        $listing_template .= "\t" . '</li>' . "\r\n";
    
        return $listing_template;
    }
    ?>

    I get the error:

    ReferenceError: terms is not defined
    ((__t=( terms ))==null?”:__t)+

    Any clue? Maybe something wrong with <%= terms %>?

    Thanks in advance.

    Thread Starter chavo

    (@chavo)

    Ok, thanks for your reply! Is it possible to display the category name for each store? If you can guide me in the right direction (I can’t find the right piece of code in the js file to modify), I think that I can arrive to a solution for displaying category icons as markers.

    Thanks in advance.

    Ok. I translated the pot file via an online po editor. I have the plugin translated to spanish until yesterday update (anyway, I think that my translation still works fine). Is there a way to upload .po and .mo files?

    OK. So there is no translation. Is there a way to get an older version with languages files? As far I can see in older versions there was an spanish translation.

    Thanks!

    ps: sorry for my english.

Viewing 15 replies - 16 through 30 (of 153 total)