【问题标题】:Woocommerce template updateWoocommerce 模板更新
【发布时间】:2018-06-05 01:12:27
【问题描述】:

我继承了一个带有子主题的网站。这个子主题有一个覆盖父主题的 Woocommerce 文件夹。我现在收到很多关于过时模板的警告。在并排比较模板之前,我已经完成了这个过程,但这次我发现模板完全不同。例如,这是最新的woocommerce“content-single-product.php”:

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 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
             * @hooked WC_Structured_Data::generate_product_data() - 60
             */
            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' );
    ?>

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

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

这就是我在这个主题中所拥有的:

<?php
/**
 * The template for displaying product content in the single-product.php template
 *
 * Override this template by copying it to yourtheme/woocommerce/content-single-product.php
 *
 * @author      WooThemes
 * @package     WooCommerce/Templates
 * @version     1.6.4
 */

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

$l = et_page_config();

$layout = etheme_get_option('single_layout');

$image_class = 'col-lg-6 col-md-6 col-sm-12'; 
$infor_class = 'col-lg-6 col-md-6 col-sm-12'; 

if($layout == 'small') {
    $image_class = 'col-lg-4 col-md-5 col-sm-12'; 
    $infor_class = 'col-lg-8 col-md-7 col-sm-12'; 
}

if($layout == 'large') {
    $image_class = 'col-sm-12'; 
    $infor_class = 'col-lg-6 col-md-6 col-sm-12'; 
}


if($layout == 'fixed') {
    $image_class = 'col-sm-6'; 
    $infor_class = 'col-lg-3 col-md-3 col-sm-12'; 
}

?>

<?php

    $class = 'tabs-'.etheme_get_option('tabs_location');
    $class .= ' single-product-'.$layout;
    $class .= ' reviews-position-'.etheme_get_option('reviews_position');
    if(etheme_get_option('ajax_addtocart')) $class .= ' ajax-cart-enable';

    /**
     * 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;
     }

    if(!etheme_get_option('product_name_signle')) {
        $class .= ' hide-product-name';
    }
?>

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

    <div class="row">
        <div class="<?php esc_attr_e( $l['content-class'] ); ?> product-content sidebar-position-<?php esc_attr_e( $l['sidebar'] ); ?>">
            <div class="row">
                <?php if ($layout == 'fixed'): ?>
                    <div class="col-md-3 product-summary-fixed">
                        <div class="fixed-product-block">
                            <div class="fixed-content">
                                <?php 
                                    woocommerce_template_single_title();
                                    woocommerce_template_single_rating();
                                    echo '<hr class="divider short">';
                                    woocommerce_template_single_excerpt();
                                    echo do_shortcode('[share title="'.__('Share Social', ET_DOMAIN).'" text="'.get_the_title().'"]');
                                 ?>
                             </div>
                         </div>
                    </div>
                <?php endif ?>
                <div class="<?php esc_attr_e( $image_class ); ?> product-images">
                    <?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><!-- Product images/ END -->

                <?php 
                    if($layout == 'large') {
                        ?>
                        </div>
                        <div class="row">
                        <?php
                    } 
                ?>

                <div class="<?php esc_attr_e( $infor_class ); ?> product-information">
                    <div class="product-information-inner <?php if($layout == 'fixed') echo 'fixed-product-block' ?>">
                        <div class="fixed-content">
                            <?php if(!etheme_get_option('product_name_signle')):  ?>
                                <h4 class="title"><?php _e('Product Information', ET_DOMAIN); ?></h4>
                            <?php endif; ?>

                            <?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
                                 */
                                do_action( 'woocommerce_single_product_summary' );
                            ?>

                            <?php if(etheme_get_option('share_icons') && $layout != 'fixed') echo do_shortcode('[share title="'.__('Share Social', ET_DOMAIN).'" text="'.get_the_title().'"]'); ?>
                        </div>
                    </div>
                </div><!-- Product information/ END -->
                <?php 
                    if($layout == 'large') {
                        ?>
                            <div class="<?php esc_attr_e( $infor_class ); ?>">
                                <?php do_action( 'woocommerce_after_single_product_summary' ); ?>
                            </div>
                        <?php
                    } 
                ?>
            </div>

            <?php
                /**
                 * woocommerce_after_single_product_summary hook
                 *
                 * @hooked woocommerce_output_product_data_tabs - 10
                 * @hooked woocommerce_output_related_products - 20 [REMOVED in woo.php]
                 */
                 if(etheme_get_option('tabs_location') == 'after_content' && $layout != 'large') {
                     do_action( 'woocommerce_after_single_product_summary' );
                 }
            ?>

        </div> <!-- CONTENT/ END -->


        <?php if($l['sidebar'] != '' && $l['sidebar'] != 'without' && $l['sidebar'] != 'no_sidebar'): ?>
            <div class="<?php esc_attr_e( $l['sidebar-class'] ); ?> single-product-sidebar sidebar-<?php esc_attr_e( $l['sidebar'] ); ?>">
                <?php et_product_brand_image(); ?>
                <?php if(etheme_get_option('upsell_location') == 'sidebar') woocommerce_upsell_display(); ?>
                <?php dynamic_sidebar('single-sidebar'); ?>
            </div>
        <?php endif; ?>
    </div>

    <?php if(etheme_get_option('upsell_location') == 'after_content') woocommerce_upsell_display(); ?>
    <?php
        if(etheme_get_custom_field('additional_block') != '') {
            echo '<div class="product-extra-content">';
                et_show_block(etheme_get_custom_field('additional_block'));
            echo '</div>';
        }     
    ?>
    <?php if(etheme_get_option('show_related')) woocommerce_output_related_products(); ?>


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

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

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

当然,使用最新的 Woocommerce 会使商店看起来不像以前那样,那么在这种情况下我应该如何处理?

【问题讨论】:

    标签: php wordpress templates woocommerce


    【解决方案1】:

    过时的文件位于您的子主题的 woocommerce 文件夹中。如果您购买了该主题,您还可以联系他们的支持人员并了解有关购买升级的信息,因为主题是否已针对兼容性进行了更新。

    如果您的模板中有重要的自定义,那么就开始将旧模板与新模板(位于插件 WooCommerce 的模板文件夹中)进行比较的超级有趣的工作。用文本打开您粘贴到主题文件夹中的模板选择的编辑器,例如 Notepad++,并将您对之前模板所做的任何更改复制到新的更新模板文件中。

    我从https://wordpress.stackexchange.com/questions/152930/how-do-i-update-woocommerce-template-files-in-my-theme找到答案

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-26
      • 1970-01-01
      • 2014-08-07
      • 2014-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多