将简短描述移动到 Woocommerce 单个产品页面的选项卡中

Move short description into tabs in Woocommerce single product pages(将简短描述移动到 Woocommerce 单个产品页面的选项卡中)
本文介绍了将简短描述移动到 Woocommerce 单个产品页面的选项卡中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在 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 单个产品页面的选项卡中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)