i have create a tabs and add multi field for tabs to Woocommerce admin tabs code
add_filter( 'woocommerce_product_data_tabs', 'vnt_woo_product_data_tabs' , 1 , 1 );
function vnt_woo_product_data_tabs( $product_data_tabs ) {
$product_data_tabs['vnt-data-tabs'] = array(
'label' => __( 'Data Tabs', 'vnthemes' ),
'target' => 'vnt_data_tabs_option',
);
return $product_data_tabs;
}
add_action( 'woocommerce_product_data_panels', 'vnt_adv_product_options_field');
function vnt_adv_product_options_field(){
global $woocommerce, $post;
echo '<div id="vnt_data_tabs_option" class="panel woocommerce_options_panel">';
woocommerce_wp_text_input(
array(
'id' => 'vntp_label',
'value' => get_post_meta( get_the_ID(), 'vntp_label', true ),
'label' => __( 'Product label', 'woocommerce' ),
'placeholder' => '1kg / 100g...',
'desc_tip' => 'true'
)
);
woocommerce_wp_checkbox( array(
'id' => 'vntp_topsale',
'value' => get_post_meta( get_the_ID(), 'vntp_topsale', true ),
'label' => 'Topsale label',
'desc_tip' => false,
) );
echo '</div>';
}
add_action( 'woocommerce_process_product_meta', 'vnt_save_fields', 10, 2 );
function vnt_save_fields( $id, $post ){
update_post_meta( $id, 'vntp_label', $_POST['vntp_label'] );
update_post_meta( $id, 'vntp_topsale', $_POST['vntp_topsale'] );
}
How to?
- If Product type is simple select:
woocommerce_product_data_panelsshow 1 data. - If Product type is variable select:
woocommerce_product_data_panelshide IDvntp_label. show IDvntp_topsale.
Any idea for my case? Thanks!

所有评论(0)