• Luca

    (@dharma23)


    How to show the opening hours in the info window?

    I’ve configured all opening hours for stores, but they’re not showing anywhere

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Hi, thank you for writing.

    The documentation for modifying the template of the info windows that pop up in the map is here: wpsl_info_window_template filter.

    You will have to insert a code snippet in your functions.php file like the one in the example from the link above and modify it to suit your needs. In order to show the opening hours you can use this article about how to show the opening hours in the search results. The mentioned article shows the hours in the wpsl_listing_template filter that prints the search results, but the info window template works pretty much in the same way.

    Consider this code snippet that I am sending you as an example:

    add_filter( 'wpsl_info_window_template', 'custom_info_window_template' );
    
    function custom_info_window_template() {
    
        global $wpsl_settings, $wpsl;
       
        $info_window_template = '<div data-store-id="<%= id %>" class="wpsl-info-window">' . "\r\n";
        $info_window_template .= "\t\t" . '<p>' . "\r\n";
        $info_window_template .= "\t\t\t" .  wpsl_store_header_template() . "\r\n";  
        $info_window_template .= "\t\t\t" . '<span><%= address %></span>' . "\r\n";
        $info_window_template .= "\t\t\t" . '<% if ( address2 ) { %>' . "\r\n";
        $info_window_template .= "\t\t\t" . '<span><%= address2 %></span>' . "\r\n";
        $info_window_template .= "\t\t\t" . '<% } %>' . "\r\n";
        $info_window_template .= "\t\t\t" . '<span>' . wpsl_address_format_placeholders() . '</span>' . "\r\n";
        $info_window_template .= "\t\t" . '</p>' . "\r\n";
        
        $info_window_template .= "\t\t" . '<% if ( phone ) { %>' . "\r\n";
        $info_window_template .= "\t\t" . '<span><strong>' . esc_html( $wpsl->i18n->get_translation( 'phone_label', __( 'Phone', 'wpsl' ) ) ) . '</strong>: <%= formatPhoneNumber( phone ) %></span>' . "\r\n";
        $info_window_template .= "\t\t" . '<% } %>' . "\r\n";
        $info_window_template .= "\t\t" . '<% if ( fax ) { %>' . "\r\n";
        $info_window_template .= "\t\t" . '<span><strong>' . esc_html( $wpsl->i18n->get_translation( 'fax_label', __( 'Fax', 'wpsl' ) ) ) . '</strong>: <%= fax %></span>' . "\r\n";
        $info_window_template .= "\t\t" . '<% } %>' . "\r\n";
        $info_window_template .= "\t\t" . '<% if ( email ) { %>' . "\r\n";
        $info_window_template .= "\t\t" . '<span><strong>' . esc_html( $wpsl->i18n->get_translation( 'email_label', __( 'Email', 'wpsl' ) ) ) . '</strong>: <%= formatEmail( email ) %></span>' . "\r\n";
        $info_window_template .= "\t\t" . '<% } %>' . "\r\n";
        
        // Include the opening hours, unless they are set to hidden on the settings page.
        if ( !$wpsl_settings['hide_hours'] ) {
            $info_window_template .= "\t\t\t" . '<% if ( hours ) { %>' . "\r\n";
            $info_window_template .= "\t\t\t" . '<p><%= hours %></p>' . "\r\n";
            $info_window_template .= "\t\t\t" . '<% } %>' . "\r\n";
        }
        
        $info_window_template .= "\t\t" . '<%= createInfoWindowActions( id ) %>' . "\r\n";
        $info_window_template .= "\t" . '</div>' . "\r\n";
        
        return $info_window_template;
    }

    That would show the opening hours in the info windows in the map.

    I hope that helps.
    Best regards,

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.