Woocommerce模板更新

问题描述 投票:1回答:1

我继承了一个有儿童主题的网站。这个子主题有一个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个回答
0
投票

过时的文件位于您孩子主题的woocommerce文件夹中。如果您购买了主题,您也可以联系他们的支持并查看有关购买升级的信息,因为主题已更新以便兼容性。

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

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

© www.soinside.com 2019 - 2024. All rights reserved.