WooCommerce 严重错误:调用未定义的方法 WC_Product_Simple::get_variation_price()

WooCommerce critical error: Call to undefined method WC_Product_Simple::get_variation_price()

提问人:Geoffrey Servant 提问时间:7/2/2023 最后编辑:LoicTheAztecGeoffrey Servant 更新时间:7/2/2023 访问量:312

问:

最近,我注意到我的 WooCommerce 网站上出现了一些严重错误。由于出现此问题,因此没有订单。

当我转到 WooCommerce -> Status -> Logs 时,我可以看到特定函数发生的许多错误。

这是堆栈跟踪:

2023-06-01T08:39:58+00:00 严重未捕获的错误:调用 /home/clients/cbade695f2a03ed1b4e40db5c6bc9ad7/web/wp-content/themes/scolax/functions.php:28 中的未定义方法 WC_Product_Simple::get_variation_price()

堆栈跟踪: #0 /home/clients/cbade695f2a03ed1b4e40db5c6bc9ad7/web/wp-includes/class-wp-hook.php(308):wpnuls_text_before_price('<span class=“wo...', Object(WC_Product_Simple))

#1 /home/clients/cbade695f2a03ed1b4e40db5c6bc9ad7/web/wp-includes/plugin.php(205):WP_Hook->apply_filters('<span class=“wo...', 数组)

#2 /home/clients/cbade695f2a03ed1b4e40db5c6bc9ad7/web/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php(1880):apply_filters('woocommerce_get...', '<span class=“wo...', Object(WC_Product_Simple))

#3 /home/clients/cbade695f2a03ed1b4e40db5c6bc9ad7/web/wp-content/plugins/woocommerce/templates/loop/price.php(25):WC_Product->get_price_html()

#4 /home/clients/cbade695f2a03ed1b4e40db5c6bc9ad7/web/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345):include('/home/clients/c...')

#5 /home/clients/c dans /home/clients/cbade695f2a03ed1b4e40db5c6bc9ad7/web/wp-content/themes/scolax/functions.php à la ligne 28

如果能得到一些帮助,我将不胜感激。谢谢!

PHP WooCommerce 方法 产品

评论

0赞 Geoffrey Servant 7/2/2023
好的,我会试试这个谢谢!我没有插入太多代码,所以我提供了一些插件,但也许主题是罪魁祸首
0赞 LoicTheAztec 7/2/2023
它与您在主题的函数 .php 文件中插入的一些自定义代码有关。相关代码使用 get_variation_price() 方法,并且不专门针对变量产品。因此,在其他产品类型上,这会产生严重错误。为避免这种情况,您需要定位“可变”产品类型,如以下代码行所示
0赞 LoicTheAztec 7/2/2023
因此,您应该在问题中提供产生此错误的相关代码函数(它使用主题函数 .php 文件中第 28 行的方法)。get_variation_price()

答: 暂无答案