woocommerce - 如何使用 Avada 子主题覆盖 Woocommerce 单一产品模板页面

标签 woocommerce

我需要重新设计产品页面的默认 woocommerce 模板。 我已经尝试将 avada 的结构复制到子主题。

/theme/avada/woocommerce/single-product/*/theme/avada-child-theme/woocommerce/single-product/

但我找不到显示整个页面的模板。只有 title.php 会更改标题。但是找不到页面的其余部分。 我需要删除这些部分:

 - short description
 - sku
 - social media buttons

如何重新设计完整的产品页面对我来说是个新问题。 可能有人可以告诉我在哪里可以找到模板。

提前致谢。 赫尔曼

    <?php
/**
 * The template for displaying product content in the single-product.php template
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/content-single-product.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer).
 * will need to copy the new files to your theme to maintain compatibility. We try to do this.
 * as little as possible, but it does happen. When this occurs the version of the template file will.
 * be bumped and the readme will list any important changes.
 *
 * @see         http://docs.woothemes.com/document/template-structure/
 * @author      WooThemes
 * @package     WooCommerce/Templates
 * @version     1.6.4
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

?>

<?php
    /**
     * woocommerce_before_single_product hook.
     *
     * @hooked wc_print_notices - 10
     */
     do_action( 'woocommerce_before_single_product' );

     if ( post_password_required() ) {
        echo get_the_password_form();
        return;
     }
?>

<div itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?>" id="product-<?php the_ID(); ?>" <?php post_class(); ?>>

    <?php
        /**
         * woocommerce_before_single_product_summary hook.
         *
         * @hooked woocommerce_show_product_sale_flash - 10
         * @hooked woocommerce_show_product_images - 20
         */
        do_action( 'woocommerce_before_single_product_summary' );
    ?>

    <div class="summary entry-summary">

        <?php
            /**
             * woocommerce_single_product_summary hook.
             *
             * @hooked woocommerce_template_single_title - 5
             * @hooked woocommerce_template_single_rating - 10
             * @hooked woocommerce_template_single_price - 10
             * @hooked woocommerce_template_single_excerpt - 20
             * @hooked woocommerce_template_single_add_to_cart - 30
             * @hooked woocommerce_template_single_meta - 40
             * @hooked woocommerce_template_single_sharing - 50
             */
         remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
            do_action( 'woocommerce_single_product_summary' );
        ?>

    </div><!-- .summary -->

    <?php
        /**
         * woocommerce_after_single_product_summary hook.
         *
         * @hooked woocommerce_output_product_data_tabs - 10
         * @hooked woocommerce_upsell_display - 15
         * @hooked woocommerce_output_related_products - 20
         */
        do_action( 'woocommerce_after_single_product_summary' );
    ?>

    <meta itemprop="url" content="<?php the_permalink(); ?>" />

</div><!-- #product-<?php the_ID(); ?> -->

<?php do_action( 'woocommerce_after_single_product' ); ?>

最佳答案

我不知道 Avada 主题,但在默认情况下,您可以在 content-single-product.php 中看到 WooCommerce通过hook 添加简短描述和社交按钮的模板。因此,要删除它们,您需要使用主题的 functions.php 中的 remove_action()

如果这不起作用,请查看 remove_action()因为您只需要确保参数与 Avada 主题的功能相匹配。

function so_35252579_remove_hooks(){
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
}
add_action( 'woocommerce_before_single_product', 'so_35252579_remove_hooks' );

要删除 SKU,您可以禁用 SKU,或者如果您需要它们但不想在前端显示它们,那么您需要覆盖 single-product/meta.php

关于woocommerce - 如何使用 Avada 子主题覆盖 Woocommerce 单一产品模板页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35252579/

相关文章:

javascript - 检查字符串是否包含任何字母(Javascript/jquery)

php - 管理产品页面自定义字段显示在购物车和结帐中

wordpress - Woocommerce - 自定义电子邮件类会创建重复的电子邮件

wordpress - 在woocommerce产品类型中隐藏选项选择项

wordpress - WooCommerce 图像缩略图相同大小

php - 从 Woocommerce 元框访问自定义函数中的 Order 对象

php - Woocommerce 按帐单名称订购

php - 在 woocommerce 结帐页面自定义字段中添加日期

php - WooCommerce Webhooks 自定义/操作不保存

php - 在 WooCommerce 存档页面中显示产品属性标签和值