hotantien
  • Laravel
  • WordPress
  • SEO
  • Đồ họa
  • Javascript
  • Download
  • Công cụ
No Result
View All Result
hotantien
No Result
View All Result
Home Wordpress

Chỉnh sửa Tab sản phẩm trong WooCommerce

in Wordpress

Các hook thường dùng để chỉnh sửa Tab trong Woocommerce

Nội dung bài viết

  1. Xóa Tab Woocommerce
  2. Đổi tên Tab Woocommerce
  3. Sắp xếp thứ tự các Tab Woocommerce
  4. Tùy chỉnh Tab Woocommerce
  5. Thêm Tab mới Woocommerce
  6. Tab “Additional Information” Woocommerce

Xóa Tab Woocommerce

/**
 * Remove product data tabs
 */
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );

function woo_remove_product_tabs( $tabs ) {

    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;
}

Đổi tên Tab Woocommerce

/**
 * Rename product data tabs
 */
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {

  $tabs['description']['title'] = __( 'More Information' );		// Rename the description tab
  $tabs['reviews']['title'] = __( 'Ratings' );				// Rename the reviews tab
  $tabs['additional_information']['title'] = __( 'Product Data' );	// Rename the additional information tab

  return $tabs;

}

Sắp xếp thứ tự các Tab Woocommerce

/**
 * Reorder product data tabs
 */
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;
}

Tùy chỉnh Tab Woocommerce

/**
 * Customize product data tabs
 */
add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
function woo_custom_description_tab( $tabs ) {

  $tabs['description']['callback'] = 'woo_custom_description_tab_content';	// Custom description callback

  return $tabs;
}

function woo_custom_description_tab_content() {
  echo '<h2>Custom Description</h2>';
  echo '<p>Here\'s a custom description</p>';
}

Thêm Tab mới Woocommerce

/**
 * 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['test_tab'] = array(
    'title' 	=> __( 'New Product Tab', 'woocommerce' ),
    'priority' 	=> 50,
    'callback' 	=> 'woo_new_product_tab_content'
  );

  return $tabs;

}
function woo_new_product_tab_content() {

  // The new tab content

  echo '<h2>New Product Tab</h2>';
  echo '<p>Here\'s your new product tab.</p>';
  
}

Tab “Additional Information” Woocommerce

Lưu ý là tab “Additional Information” sẽ chỉ hiển thị nếu sản phẩm có trọng lượng, kích thước hoặc thuộc tính (không được sử dụng cho biến thể cho các sản phẩm khác nhau). Nếu bạn cố gắng áp dụng thay đổi cho tab đó và nếu sản phẩm không có trọng lượng, kích thước hoặc thuộc tính, bạn sẽ nhận được thông báo lỗi tương tự như:

Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in /mysite/wp-content/plugins/woocommerce/templates/single-product/tabs/tabs.php on line 35

Trong trường hợp đó, bạn phải sử dụng thẻ điều kiện WooC Commerce:

  • has_attribut ()
  • has_dimensions ()
  • has_ weight ()
Source: Editing product data tabs
Tags: Product TabWoocommerce
ShareShareSend
Hồ Tân Tiến

Hồ Tân Tiến

I'm TIEN, a passionate explorer in the realms of programming, SEO, and marketing. This blog, encapsulated by the slogan "Explore, Grow, and Outshine - EGO", is my personal space to archive and share knowledge that I've accumulated over the years. I believe in continuous learning and hope that the insights I share here help you on your journey. Dive in, let's grow together!

Theo dõi
Đăng nhập
Thông báo của
guest
guest
0 Góp ý
Phản hồi nội tuyến
Xem tất cả bình luận

Bài viết mới nhất

Validate Email trong Laravel

Validate hình ảnh base64 Laravel

[SEO Onpage] 200 yếu tố xếp hạng của Google: Onpage

Tất cả Shortcode WooCommerce

VPS / Hosting nên dùng

  • Azdigi.com
  • Vietnix.vn

Liên kết

  • Tranhuuvan.com
  • Tienemall.com

Resource

  • Freepik.com
  • Flaticon.com
  • Unsplash.com

© 2022 Blog của Tiến - Hosted by AZDigi

No Result
View All Result
  • Laravel
  • WordPress
  • SEO
  • Đồ họa
  • Javascript
  • Download
  • Công cụ

© 2022 Blog của Tiến - Hosted by AZDigi

wpDiscuz
0
0
Rất thích suy nghĩ của bạn, hãy bình luận.x
()
x
| Trả lời