我有一个旧主题,我认为它与woocommerce的新版本不再兼容。我的网站显示错误
致命错误:未捕获错误:调用未定义的方法 WooCommerce :: get_image_size()在 /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): 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-includes/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(Array)#5 /home3/lohasfarms/public_html/adohrmilkcream.com/wp-content/themes/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-->
非常感谢您
答案 0 :(得分:0)
我找到了一个临时解决方案
只需遵循错误的路径并注释这样的代码
// 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可以运行 希望这会为谁得到相同的错误提供帮助