I solved my problem using the the field type “checkbox” although it will be nice if there is a solution if someone want to use the field type “dropdown”.
Creating a new tab with the custom fields with the filter “wpsl_meta_box_fields” https://wpstorelocator.co/document/add-custom-meta-data-to-store-locations/:
add_filter( 'wpsl_meta_box_fields', 'custom_meta_box_fields' );
function custom_meta_box_fields( $meta_fields ) {
$meta_fields[__( 'Additional Stockist Information', 'wpsl' )] = array(
'retail_store_orders' => array(
'label' => __( 'Retail Store Orders?', 'wpsl' ),
'type' => 'checkbox',
),
'website_orders' => array(
'label' => __( 'Website Orders?', 'wpsl' ),
'type' => 'checkbox',
),
'email_orders' => array(
'label' => __( 'Email Orders?', 'wpsl' ),
'type' => 'checkbox',
),
);
return $meta_fields;
}
Including additional meta data in the JSON response on the front end with the filter “wpsl_frontend_meta_fields” https://wpstorelocator.co/document/wpsl_frontend_meta_fields/
add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' );
function custom_frontend_meta_fields( $store_fields ) {
$store_fields['wpsl_retail_store_orders'] = array(
'name' => 'retail_store_orders',
'type' => 'checkbox'
);
$store_fields['wpsl_website_orders'] = array(
'name' => 'website_orders',
'type' => 'checkbox'
);
$store_fields['wpsl_email_orders'] = array(
'name' => 'email_orders',
'type' => 'checkbox'
);
return $store_fields;
}
Creating a custom template with the filter wpsl_listing_template to show the custom fields https://wpstorelocator.co/?s=wpsl_listing_template&post_type=wpsl_doc
/////
// Showing Custom option to order via website, Local store or phone
////
$listing_template .= "\t\t" . '<div class="order-via">' . "\r\n";
// retail store order
$listing_template .= "\t\t\t" . '<% if ( retail_store_orders ) { %>' . "\r\n";
$listing_template .= "\t\t\t" . '<p class="retail_store">' . __( '<span>Retail Store</span>', 'wpsl' ) . '</p>' . "\r\n";
$listing_template .= "\t\t\t" . '<% } %>' . "\r\n";
// website order
$listing_template .= "\t\t\t" . '<% if ( website_orders ) { %>' . "\r\n";
$listing_template .= "\t\t\t" . '<p class="website">' . __( '<span>Website</span>', 'wpsl' ) . '</p>' . "\r\n";
$listing_template .= "\t\t\t" . '<% } %>' . "\r\n";
// phoe order
$listing_template .= "\t\t\t" . '<% if ( email_orders ) { %>' . "\r\n";
$listing_template .= "\t\t\t" . '<p class="mail_order">' . __( '<span>Mail Order</span>', 'wpsl' ) . '</p>' . "\r\n";
$listing_template .= "\t\t\t" . '<% } %>' . "\r\n";
$listing_template .= "\t\t" . '</div>' . "\r\n";
/////
// END Showing Custom option to order via website, Local store or phone
////
-
This reply was modified 7 years, 10 months ago by
andresgl.