WooCommerce Additional Information Table Extra Rows

Its about Woocommerce additional information tab, i want to add new rows in table and i used this hook;

function my_extra_fields($product_attributes, $product){
$product_attributes[‘UrunEnerji’] = [
‘label’ => __(‘Enerji’, ‘text-domain’),
‘value’ => get_post_meta($product->get_ID(), ‘UrunEnerji’, true),
];
$product_attributes[‘UrunYag’] = [
‘label’ => __(‘Yağ’, ‘text-domain’),
‘value’ => get_post_meta($product->get_ID(), ‘UrunYag’, true),
];
$product_attributes[‘UrunDoymusYag’] = [
‘label’ => __(‘Doymuş Yağ’, ‘text-domain’),
‘value’ => get_post_meta($product->get_ID(), ‘UrunDoymusYag’, true),
];
$product_attributes[‘UrunSeker’] = [
‘label’ => __(‘Şeker’, ‘text-domain’),
‘value’ => get_post_meta($product->get_ID(), ‘UrunSeker’, true),
];
$product_attributes[‘UrunTuz’] = [
‘label’ => __(‘Tuz’, ‘text-domain’),
‘value’ => get_post_meta($product->get_ID(), ‘UrunTuz’, true),
];
$product_attributes[‘UrunProtein’] = [
‘label’ => __(‘Protein’, ‘text-domain’),
‘value’ => get_post_meta($product->get_ID(), ‘UrunProtein’, true),
];
$product_attributes[‘UrunLif’] = [
‘label’ => __(‘Lif’, ‘text-domain’),
‘value’ => get_post_meta($product->get_ID(), ‘UrunLif’, true),
];
return $product_attributes;
}
add_filter(‘woocommerce_display_product_attributes’, ‘my_extra_fields’, 10, 2);

Now you can add custom fields from wordpress like “UrunEnerji” and configure your value.

After that, i need to add header and footer text on table like this:

add_filter( ‘woocommerce_product_tabs’, ‘woo_rename_tabs’, 98 );
function woo_rename_tabs( $tabs ) {
global $product;
$tabs[‘additional_information’][‘callback’] = ‘mytexts’;
return $tabs;
}

function mytexts(){
echo ‘<p>table header text</p>’;
woocommerce_product_additional_information_tab();
echo ‘<p style=”margin-top: 15px;”>table footer text</p>’;
}

Good luck with sales!

Written by Uğur

Comments (2)

  1. I’m amazed, I must say. Seldom do I encounter a blog
    that’s equally educative and interesting, and let me tell you, you’ve hit the
    nail on the head. The issue is an issue that not enough folks are speaking intelligently about.
    I am very happy I found this in my search for something regarding this.

Leave a Reply

Your email address will not be published. Required fields are marked *