Adding a new Tab on Product detail page in woo commerce
- سُلَيْمَان بْن دَاوُوْد

- Jun 21, 2020
- 1 min read
/**
* Add a custom product data tab
*/
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
/**
* Adds the new tab
*/
$tabs['health'] = array(
'title' => __( 'Health', 'woocommerce' ),
'priority' => 10,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
function woo_new_product_tab_content() {
global $product;
$product_id = $product->get_ID();
//$link = get_field('links_to_resources_to_support_health_benefits');
$link2 = get_field('commonly_used_for');
echo 'Related Resource:';
if( have_rows('new_rept') ):
while ( have_rows('new_rept') ) : the_row();
$link = get_sub_field('list_of_links');
echo '<p style="margin-bottom: 0;"><a target="_blank" href="'.$link.'">'.$link.'</a></p>';
endwhile;
endif;
echo '<p class="link2text">'.$link2.'</p>';
}

Comments