Woocommerce出现致命错误:未捕获错误:调用未定义的方法Woocommerce::get_image_size()

Woocommerce出现致命错误:未捕获错误:调用未定义的方法Woocommerce::get_image_size(),woocommerce,woocommerce-theming,Woocommerce,Woocommerce Theming,我有一个旧的主题,我认为它与woocommerce的新版本不再兼容。我的网站显示错误 致命错误:未捕获错误:调用未定义的方法 WooCommerce::在中获取图像大小() /home3/lohasfarms/public_html/adohrmilkcream.com/wp content/themes/adohrmilkcream/woocommerce/single product/product thumbnails.php:16 堆栈跟踪:#0 /home3/lohasfarms/pu

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

致命错误:未捕获错误:调用未定义的方法 WooCommerce::在中获取图像大小() /home3/lohasfarms/public_html/adohrmilkcream.com/wp content/themes/adohrmilkcream/woocommerce/single product/product thumbnails.php:16 堆栈跟踪:#0 /home3/lohasfarms/public_html/adohrmilkcream.com/wp content/plugins/woocommerce/includes/wc core functions.php(211): 包括()#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 includes/class wp hook.php(286): woocommerce_show_product_缩略图(“”)3 /home3/lohasfarms/public_html/adohrmilkcream.com/wp includes/class wp hook.php(310): WP_Hook->应用_过滤器('',数组)#4 /home3/lohasfarms/public_html/adohrmilkcream.com/wp includes/plugin.php(453): WP#u Hook->do_action(数组)#5 /home3/lohasfarms/public_html/adohrmilkcream.com/wp content/themes/adohrmilkcream/woocommerce/single product/product image.php(36): 采取行动('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-->


非常感谢

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

只需遵循错误路径并像下面这样注释代码

// 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'];
}
//如果小于2.0
如果(版本比较)(版本'2.0','