Frontend datetime picker
-
Hello,
Is it possible to include in frontend the datetime picker js css since its only for backend ?I am using wc marketplace and since its not supporting metabox fields (yet) i used some of theyr actions to add the field in frontend.
This is my metafield:add_filter( 'rwmb_meta_boxes', 'theme_meta_boxes' ); function theme_meta_boxes( $meta_boxes ) { $meta_boxes[] = array( 'title' => __( 'Event Information', 'theme-slug' ), 'post_types' => 'product', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'id' => 'event_date', 'name' => __( 'Event Date', 'theme-slug' ), 'type' => 'datetime', 'js_options' => array( 'dateFormat' => 'dd-mm-yy', 'showTimepicker' => true, 'stepMinute' => 15, ), 'save_format' => 'd-m-Y H:i:s', 'timestamp' => true, ), ), ); return $meta_boxes; }In frontend i add the following actions in functions.php to get my field :
function add_custom_product_data_tabs( $tabs ) { $tabs['advanced'] = array( 'label' => __( 'Event date', 'your-text-domain' ), 'target' => 'event_date_tab', 'class' => array(), 'priority' => 100, ); return $tabs; } add_filter( 'wcmp_product_data_tabs', 'add_custom_product_data_tabs' ); function add_custom_product_data_content( $pro_class_obj, $product, $post ) { $get_value = get_post_meta($post->ID,'event_date'); ?> <div role="tabpanel" class="tab-pane fade" id="event_date_tab"> <div class="row-padding"> <div class="form-group"> <label class="control-label col-sm-3 col-md-3">Event Date</label> <div class="col-md-6 col-sm-9"> <input type="text" name="event_date" class="form-control" value="<?php echo $get_value[0] ?>" /> </div> </div> </div> </div> <?php } add_action( 'wcmp_product_tabs_content', 'add_custom_product_data_content', 10, 3 ); function save_custom_product_data( $product, $post_data ) { if( isset($post_data['post_ID']) && isset($post_data['event_date'])){ update_post_meta( absint( $post_data['post_ID'] ), 'event_date', $post_data['event_date']); } } add_action( 'wcmp_process_product_object', 'save_custom_product_data', 10, 2 );So is it possible to make the field works the sameway as in backend ? Since i want to keep the format of the date and time and stepMinute to be per 15.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Frontend datetime picker’ is closed to new replies.