// Reorder product tab woocommerce
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
$tabs['additional_information']['priority'] = 15; // Additional information third
return $tabs;
}
// Đổi tên và ẩn product tabs
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
$tabs['description']['title'] = __( 'Giới thiệu' ); // Change tab name
//unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
// Gọi product tabs ra ngoài
add_action( 'woocommerce_after_single_product_summary', 'removing_product_tabs', 2 );
function removing_product_tabs(){
remove_action('woocommerce_after_single_product_summary','woocommerce_output_product_data_tabs', 10 );
add_action('woocommerce_after_single_product_summary','get_product_tab_templates_displayed', 10 );
}
function get_product_tab_templates_displayed() {
wc_get_template( 'single-product/tabs/description.php' );
wc_get_template( 'single-product/tabs/additional-information.php' );
comments_template();
}
// Tạo nút liên hệ cho sản phẩm ko đề giá
add_filter('woocommerce_empty_price_html', 'custom_for_price');
function custom_for_price() {
global $product;
$fv_button = '<a href="link_trang_liên_hệ_vào_đây" class="fv-contact-button">Liên hệ</a>';
$fv_tt1 = '<ul class="fv-tt-single"><li><label>Mã SP: </label>'.$product->get_sku().'</li>';
$fv_tt1 .= '<li><label>Xuất Xứ: </label>'.$product->get_attribute( 'pa_xuat-xu' ).'</li>';
$fv_tt1 .= '<li><label>Bảo Hành: </label>'.$product->get_attribute( 'pa_bao-hanh' ).'</li>';
$fv_tt1 .= '<li><label>Giá: </label><strong>Call</strong></li>';
$fv_tt1 .= '<li><label>Quà Tặng: </label>'.$product->get_attribute( 'pa_qua-tang' ).'</li></ul>';
if(!is_single()){
return $fv_button;
}else{
return $fv_tt1;
}
}
// Chuyển product category description xuống cuối trang
add_action( 'wp', 'tu_move_wc_archive_description' );
function tu_move_wc_archive_description() {
if ( is_archive() ) {
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 );
add_action( 'woocommerce_after_main_content', 'woocommerce_taxonomy_archive_description', 10 );
add_action( 'woocommerce_after_main_content', 'woocommerce_product_archive_description', 10 );
}
}
// Bỏ phần thập phân nếu giá trị price bằng 0 vd: $29.0 => $29
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );
}