Profile image
Tác giả: fcwordpress
Trang tin cá nhân | Bài đã đăng
Lượt xem

Hiện tại:
1h trước:
24h trước:
Tổng số:
Product data tabs trong woocommerce là gì?
Wednesday, October 14, 2015 21:42
% of readers think this story is Fact. Add your two cents.
0

Product data tabs trong woocommerce chính là thanh chức năng hiển thị description của product, reviews..

B4INREMOTE-aHR0cDovL2Zjd29yZHByZXNzLm5ldC93cC1jb250ZW50L3VwbG9hZHMvMjAxNS8wMS9Qcm9kdWN0LWRhdGEtdGFicy1sYS1naS5wbmc=

Như thế nào để anh chị tùy biến thanh này, hôm nay tôi sẽ chia sẽ các code để làm việc này

  • Xóa tab:

add_filter( ‘woocommerce_product_tabs’, ‘woo_remove_product_tabs’, 98 );

function woo_remove_product_tabs( $tabs ) {

unset( $tabs[‘description’] ); // Xóa  tab description
unset( $tabs[‘reviews’] ); // Xóa tab reviews

return $tabs;

}

  • Thay đổi tên tab:

add_filter( ‘woocommerce_product_tabs’, ‘woo_rename_tabs’, 98 );
function woo_rename_tabs( $tabs ) {

$tabs[‘description’][‘title’] = __( ‘Mô tả’ );
$tabs[‘reviews’][‘title’] = __( ‘Ý kiến khách hàng’ );

return $tabs;

}

  • Thay đổi thứ tự tab

add_filter( ‘woocommerce_product_tabs’, ‘woo_reorder_tabs’, 98 );
function woo_reorder_tabs( $tabs ) {

$tabs[‘reviews’][‘priority’] = 5; // Tab Reviews ở vị trí đầu tiên thay vì ở vị trí thứ 2
$tabs[‘description’][‘priority’] = 10; // Tab Description ở vị trí 1

return $tabs;
}

  • Thêm tab vào thanh tab

Điều này thì hữu ích khi ta muốn thêm một tab để hiển thị các image của sản phẩm chẳn hạn

add_filter( ‘woocommerce_product_tabs’, ‘image_product_tab’ );
function image_product_tab( $tabs ) {

//thêm vào tab để chứa image sản phẩm

$tabs[‘image_sp’] = array(
‘title’ => __( ‘Hình ảnh sản phẩm’, ‘woocommerce’ ),
‘priority’ => 50,
‘callback’ => ‘function_lay_image_sp’
);

return $tabs;

}
function function_lay_image_spt() {

// Viết code lấy image của sản phẩm tại đây

}

  • Chỉ sửa tab hiện có của woocommerce

add_filter( ‘woocommerce_product_tabs’, ‘custom_description_tab’, 98 );
function woo_custom_description_tab( $tabs ) {

$tabs[‘description’][‘callback’] = ‘function_lam_viec_nay’; // hàm để thay đổi cách hiển thị description

return $tabs;
}

function function_lam_viec_nay() {
// viết code làm điều này tại đây
}

Hị vọng sẽ giúp được anh chị qua bài viết Product data tabs trong woocommerce là gì?

Từ khóa tìm kiếm trên google:

-Product data tabs trong woocommerce là gì?

-Thay đổi tabs description trong woocommerce

-Thay đổi tabs review trong woocommerce

-Thêm tabs mới vào thanh tabs woocommerce

BÌNH LUẬN

Lời bình của bạn
Question   Razz  Sad   Evil  Exclaim  Smile  Redface  Biggrin  Surprised  Eek   Confused   Cool  LOL   Mad   Twisted  Rolleyes   Wink  Idea  Arrow  Neutral  Cry   Mr. Green

Tin nổi bật trong ngày
Tin mới nhất

Register

Newsletter

Email this story
Share This Story:
Print this story
Email this story
Digg
Reddit
StumbleUpon
Share on Tumblr
GET ALERTS:

If you really want to ban this commenter, please write down the reason:

If you really want to disable all recommended stories, click on OK button. After that, you will be redirect to your options page.