Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gizalink/ae5f69d25a77a659210f to your computer and use it in GitHub Desktop.
Save gizalink/ae5f69d25a77a659210f to your computer and use it in GitHub Desktop.
<?php
//Ham kiem tra, neu san pham khong co mieu ta se thay the bang tab mieu ta custom
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {
$id_product = get_the_id(); //get id product
$temp = get_post($id_product)->post_content; //get content
if($temp){ //kiem tra
return $tabs;
}else{
$tabs['description'] = array(
'title' => __( 'New Product Tab', 'woocommerce' ),
'priority' => 5,
'callback' => 'woo_custom_description_tab_content'
);
return $tabs;
}
}
//Ham noi dung tab
function woo_custom_description_tab_content() {
echo '<h2>Custom Description</h2>';
echo '<p>Here\'s a custom description</p>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment