Woocommerce 出现致命错误:未捕获的错误:调用未定义的方法 WooCommerce::get_image_size()
Posted
技术标签:
【中文标题】Woocommerce 出现致命错误:未捕获的错误:调用未定义的方法 WooCommerce::get_image_size()【英文标题】:Woocommerce got Fatal error: Uncaught Error: Call to undefined method WooCommerce::get_image_size() 【发布时间】:2019-03-14 19:26:25 【问题描述】:我有一个旧主题,我认为它不再与新版本的 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): 包括()#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('', Array) #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 class="product_image attachment-shop_single wp-post-image" 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" 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); ?>" />
</a>
<?php endif; ?>
<?php
global $main_image_height;
$main_image_height = $image_height;
do_action('woocommerce_product_thumbnails');
?>
</div><!--close imagecol-->
非常感谢
【问题讨论】:
【参考方案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可以运行 希望这对遇到相同错误的人有所帮助
【讨论】:
以上是关于Woocommerce 出现致命错误:未捕获的错误:调用未定义的方法 WooCommerce::get_image_size()的主要内容,如果未能解决你的问题,请参考以下文章
无法使用 gmail SMTP 在 Zend 中发送电子邮件。出现致命错误:未捕获的异常“Zend_Mail_Protocol_Exception”。如何解决这个问题?
致命错误:未捕获的错误:未找到“Omnipay\Omnipay”类