問題描述
我正在嘗試將附加信息選項卡與 WooCommerce 中的描述選項卡合并.
I am trying to merge the additional information tab with the description tab in WooCommerce.
目的是在 2 列布局中并排顯示來自兩個選項卡的信息,其中第一列顯示說明,第二列顯示附加信息.
The intention is to display information from both tabs side-by-side in a 2-column layout, where the first column displays the description and the second column the additional information.
這可以用一段可以放在functions.php中的代碼來實現嗎?
Can this be achieved with a piece of code that can be placed in functions.php?
推薦答案
我最終采用了稍微不同的方法,基本上只是禁用了附加詳細信息選項卡并將內容重新添加到 the_content
產品(即普通的描述"選項卡).
I ended up taking a slightly different approach, basically just disabled the Additional Details tab and re-adding the content to the_content
of the product (that is, the normal Description tab).
// Remove Additional Info tab
add_filter('woocommerce_product_tabs', 'remove_tab_additional_info', 30);
function remove_tab_additional_info($tabs){
unset( $tabs['additional_information'] );
return $tabs;
}
// Add original Additional Info tab info to the end of the_content
add_filter('the_content','add_details_to_content', 10, 1);
function add_details_to_content($content){
if ( is_product() ){
global $product;
$content = '<div class="product-description">'.$content.'</div>';
ob_start();
?><div class="product-additional-info"><?php
$heading = apply_filters( 'woocommerce_product_additional_information_heading', __( 'Additional information', 'woocommerce' ) );
if ( !empty($heading) ) {
?>
<h3><?php echo esc_html( $heading ); ?></h3>
<?php }
do_action( 'woocommerce_product_additional_information', $product );
?></div><?php
$content .= ob_get_clean();
}
return $content;
}
這篇關于如何在 WooCommerce 中合并描述和附加信息選項卡?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!