How can I merge the Description and Additional Information tabs in WooCommerce?(如何在 WooCommerce 中合并描述和附加信息选项卡?)
问题描述
我正在尝试将附加信息选项卡与 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 中合并描述和附加信息选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 WooCommerce 中合并描述和附加信息选项卡


- SoapClient 设置自定义 HTTP Header 2021-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Laravel 仓库 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01