0

I need some help with the Singleproduct page, especially with the tabs i took a code snippet to add a different tab. that works fine. but all of the text is in one line. However, the text is always continuous text. I aknn't add paragraphs, neither via TAB nor via

Is there a solution or an alternative to CodeSnippet?

My code is as follows:

add_filter('woocommerce_product_data_tabs', 'misha_product_settings_tabs' );
function misha_product_settings_tabs( $tabs ){
 
    //unset( $tabs['inventory'] );
 
    $tabs['misha'] = array(
        'label'    => 'Misha',
        'target'   => 'misha_product_data',
    );
    return $tabs;
 
}
 
/*
 * Tab content
 */
add_action( 'woocommerce_product_data_panels', 'misha_product_panels' );
function misha_product_panels(){
 
    echo '<div id="misha_product_data" class="panel woocommerce_options_panel hidden">';
 
    woocommerce_wp_text_input( array(
        'id'                => '_category_head_name',
        'value'             => get_post_meta( get_the_ID(), '_category_head_name', true ),
        'label'             => 'Überschrift der Kategorie',
        'description'       => 'Description when desc_tip param is not true'
    ) );
 
    woocommerce_wp_textarea_input( array(
        'id'          => '_text_cat',
        'value'       => get_post_meta( get_the_ID(), '_text_cat', true ),
        'label'       => 'Content',
        'desc_tip'    => true,
        'description' => 'Prove the plugin changelog here',
    ) );
 

 
    echo '</div>';
 
}

add_action( 'woocommerce_process_product_meta', 'woocommerce_process_product_meta_fields_save' );
function woocommerce_process_product_meta_fields_save( $post_id ){
    // This is the case to save custom field data of checkbox. You have to do it as per your custom fields
   $woocommerce_text_field = $_POST['_category_head_name'];
    if( !empty( $woocommerce_text_field ) )
        update_post_meta( $post_id, '_category_head_name', esc_attr( $woocommerce_text_field ) );
    $woocommerce_textarea = $_POST['_text_cat'];
    if( !empty( $woocommerce_textarea ) )
        update_post_meta( $post_id, '_text_cat', esc_html( $woocommerce_textarea ) );
}

add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
    
    // Adds the new tab
    
    $tabs['test_tab'] = array(
        'title'     => __( get_post_meta( get_the_ID(), '_category_head_name', true ), 'woocommerce' ),
        'priority'  => 50,
        'callback'  => 'woo_new_product_tab_content'
    );

    return $tabs;
}

function woo_new_product_tab_content() {

    // The new tab content

    echo  get_post_meta( get_the_ID(), '_text_cat', true )  ;
    
}

0

Browse other questions tagged or ask your own question.