I used the code posted by ClemC in Woocommerce add extra field to variation product with a textarea instead of a text_input. I succeeded to show my textarea under wooocommerce-default "variation description" textarea. I also succeeded to show my textarea information in the product description tab. However, the information does not keep their format (the html format is taken as text and the breaklineas are ignored).
For example, if I fill my textarea with:
row1
<b>row2</b></br>
row3
the next is shown in the product description tab:
row1 <b>row2</b></br> row3
If I go back to my textarea in the product description after updating, the information appears modified to:
row1
<b>row2</b></br>
row3
I will appreciate any help in order to keep the format in my textarea, as happens if I use the wooocommerce-default "variation description" textarea.
Change part of my code to:
function save_variation_settings_fields( $variation_id, $loop ) {
$text_field = $_POST['my_text_field'][ $loop ];
if ( ! empty( $text_field )) {
if ( ! current_user_can( 'unfiltered_html' ) ) {
$text_field = wp_kses_post( $text_field );}
update_post_meta( $variation_id, 'my_text_field', $text_field ); }}
function load_variation_settings_fields( $variation ) {
$variation['my_text_field'] = wpautop( get_post_meta( $variation[ 'variation_id' ], 'my_text_field', true ) );
return $variation; }
And now everything works like a charm. Thanks a lot Jacob!