0

我有一个旧主题,我认为它不再与新版本的 woocommerce 兼容。我的网站显示错误

致命错误:未捕获错误:调用 /home3/lohasfarms/public_html/adohrmilkcream.com/wp-content/themes/AdohrMilkCream/woocommerce/single-product/product-thumbnails.php:16 中未定义的方法 WooCommerce::get_image_size()跟踪:#0 /home3/lohasfarms/public_html/adohrmilkcream.com/wp-content/plugins/woocommerce/includes/wc-core-functions.php(211):include() #1 /home3/lohasfarms/public_html/adohrmilkcream。 com/wp-content/plugins/woocommerce/includes/wc-template-functions.php(1053): wc_get_template('single-product/...') #2 /home3/lohasfarms/public_html/adohrmilkcream.com/wp-包括/class-wp-hook.php(286): woocommerce_show_product_thumbnails('') #3 /home3/lohasfarms/public_html/adohrmilkcream.com/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters ('',数组)#4 /home3/lohasfarms/public_html/adohrmilkcream.com/wp-includes/plugin.php(453):WP_Hook->do_action(数组)#5 /home3/lohasfarms/public_html/adohrmilkcream.com/wp-content/主题/AdohrMilkCream/woocommerce/single-product/product-image.php(36): do_action('woocom in /home3/lohasfarms/public_html/adohrmilkcream.com/wp-content/themes/AdohrMilkCream/woocommerce/single-product/product -thumbnails.php 第 16 行

你能帮忙找出我应该为这个问题做些什么吗?

这是我的 /public_html/adohrmilkcream.com/wp-content/themes/AdohrMilkCream/woocommerce/single-product/product-thumbnails 的代码

 <?php
/**
 * Single Product Image
 */

global $post, $woocommerce, $product;

// if less than 2.0
if ( version_compare( WOOCOMMERCE_VERSION, '2.0', '<' ) ) { 
    //$image_width = get_option( 'woocommerce_single_image_width' );
    //$image_height = get_option( 'woocommerce_single_image_height' );
} else {            
    $image_sizes = $woocommerce->get_image_size( 'shop_single' );
    $image_width = $image_sizes['width'];
    $image_height = $image_sizes['height'];
}

?>
<div class="imagecol images">
    <?php if ( has_post_thumbnail() ) : ?>

        <a data-rel="prettyPhoto[<?php echo $post->ID; ?>]" href="<?php echo sp_get_image($post->ID); ?>" class="zoom thickbox preview_link" title="<?php the_title_attribute(); ?>" data-id="<?php echo $post->ID; ?>" onclick="return false;">
        <img width="<?php echo $image_width; ?>" height="<?php echo $image_height; ?>" class="product_image attachment-shop_single wp-post-image" alt="<?php the_title_attribute(); ?>" src="<?php echo sp_timthumb_format('single_main', sp_get_image($post->ID), $image_width, $image_height); ?>" />
        </a>

    <?php else : ?>

        <a data-rel="prettyPhoto[<?php echo $post->ID; ?>]" class="zoom thickbox preview_link" href="<?php echo get_template_directory_uri(); ?>/images/no-product-image.jpg" title="<?php the_title_attribute(); ?>" data-id="<?php echo $post->ID; ?>" onclick="return false;">
        <img class="no-image" alt="No Image" title="<?php the_title_attribute(); ?>" src="<?php echo sp_timthumb_format('single_main', get_template_directory_uri().'/images/no-product-image.jpg', $image_width, $image_height); ?>" width="<?php echo $image_width; ?>" height="<?php echo $image_height; ?>" />
        </a>

    <?php endif; ?>            
  <?php 
      global $main_image_height; 
      $main_image_height = $image_height;   
      do_action('woocommerce_product_thumbnails');
  ?>
</div><!--close imagecol-->

太感谢了

4

1 回答 1

1

我找到了一个临时解决方案

只需按照错误的路径并像这样注释代码

// if less than 2.0
if ( version_compare( WOOCOMMERCE_VERSION, '2.0', '<' ) ) { 
    $image_width = get_option( 'woocommerce_single_image_width' );
    $image_height = get_option( 'woocommerce_single_image_height' );
} else {            
    //$image_sizes = $woocommerce->get_image_size( 'shop_single' );
    //$image_width = $image_sizes['width'];
    //$image_height = $image_sizes['height'];
}

然后woocommerce可以运行希望这将帮助谁得到同样的错误

于 2018-10-10T20:28:28.793 回答