在 woocommerce 单一产品页面中,如何将产品简短描述移动到自定义产品选项卡中,其中描述和附加信息?
In woocommerce Single Product pages, how do I move the product short description into a custom product tab where the description and the additional information are?
我已将描述和附加信息选项卡从标准位置移至产品摘要所在的右侧.但是,我想将产品摘要插入到一个选项卡中,因此基本上它将是 3 个选项卡.
I have moved the description and additional information tab from the standard position to the right side where the product summary is. However I would like to insert the product summary into a tab so essentially it will be 3 tabs.
我用来将标签移动到图像右侧的代码是:
The code I have used to move the tabs to the right of the image is:
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 30 );
您仍然保留以下更改选项卡位置的内容(就像您已经做的那样):
You still keep the following that change the tabs location (as you already do):
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 30 );
然后,以下内容会将简短描述的位置更改为自定义产品选项卡:
Then, the following will change the location of short description to a custom product tab:
// Remove short description
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
// Add short description to a custom product tab
add_filter( 'woocommerce_product_tabs', 'add_custom_product_tab', 10, 1 );
function add_custom_product_tab( $tabs ) {
$custom_tab = array(
'custom_tab' => array(
'title' => __( "Short description", "woocommerce" ),
'priority' => 12,
'callback' => 'short_description_tab_content'
)
);
return array_merge( $custom_tab, $tabs );
}
// Custom product tab content
function short_description_tab_content() {
global $post, $product;
$short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );
if ( ! $short_description ) {
return;
}
echo '<div class="woocommerce-product-details__short-description">' . $short_description . '</div>'; // WPCS: XSS ok.
}
代码位于活动子主题(或活动主题)的 function.php 文件中.经测试有效.
Code goes on function.php file of your active child theme (or active theme). Tested and works.
这篇关于将简短描述移动到 Woocommerce 单个产品页面的选项卡中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
以编程方式将可下载文件添加到 Woocommerce 产品Add programmatically a downloadable file to Woocommerce products(以编程方式将可下载文件添加到 Woocommerce 产品)
获取今天 Woocommerce 中每种产品的总订单数Get today#39;s total orders count for each product in Woocommerce(获取今天 Woocommerce 中每种产品的总订单数)
在 WooCommerce 和电话字段验证问题中添加自定义注Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和电话字段验证问题中添加自定义注册字段
在 Woocommerce 简单产品中添加一个将更改价格的选Add a select field that will change price in Woocommerce simple products(在 Woocommerce 简单产品中添加一个将更改价格的选择字段)
在 WooCommerce 3 中将自定义列添加到管理产品列表Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中将自定义列添加到管理产品列表)
自定义结帐“下订单"按钮输出htmlCustomizing checkout quot;Place Orderquot; button output html(自定义结帐“下订单按钮输出html)