I would like to insert a unique text into the information windows located beneath the Store details (below Email).
https://i.sstatic.net/2ItMW.jpg
Following the guidelines from:
To implement this feature, I made the necessary adjustments in the function.php file of the WordPress theme:
// custom_textinput field addition
add_filter( 'wpsl_meta_box_fields', 'custom_meta_box_fields' );
function custom_meta_box_fields( $meta_fields ) {
$meta_fields[__( 'Additional Information', 'wpsl' )] = array(
'phone' => array(
'label' => __( 'Tel', 'wpsl' )
),
'fax' => array(
'label' => __( 'Fax', 'wpsl' )
),
'email' => array(
'label' => __( 'Email', 'wpsl' )
),
'url' => array(
'label' => __( 'Url', 'wpsl' )
),
'my_textinput' => array(
'label' => __( 'Textinput', 'wpsl' )
)
);
return $meta_fields;
}
// incorporation of my_textinput into the JSON response
function custom_frontend_meta_fields( $store_fields ) {
$store_fields['wpsl_my_textinput'] = array(
'name' => 'my_textinput',
'type' => 'text'
);
return $store_fields;
}
// showcasing my_textinput on the frontend info window
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";
// Remaining template code shortened for brevity...
return $info_window_template;
}
After appending the subsequent section of code (close to the end), the info windows cease to display:
$info_window_template .= "\t\t" . '<% if ( my_textinput ) { %>' . "\r\n";
$info_window_template .= "\t\t" . '<p><%= my_textinput %></p>' . "\r\n";
$info_window_template .= "\t\t" . '<% } %>' . "\r\n";
The Developer Tools console shows the following error message:
Uncaught ReferenceError: my_textinput is not defined
at eval (eval at m.template (underscore.min.js?ver=1.8.3:5), <anonymous>:52:2)
at c (underscore.min.js?ver=1.8.3:5)
at H (wpsl-gmap.min.js?ver=2.2.15:1)
at _.ze.<anonymous> (wpsl-gmap.min.js?ver=2.2.15:1)
at Object.trigger ...
How can I ensure that the data is included in the JSON output?