个性化阅读
专注于IT技术分析

在第790行的config-woocommerce/config.php中的非对象上调用成员函数get_cart_subtotal()

点击下载

我正在尝试登录WordPress管理面板, 并遇到以下错误:

在第790行的/home/spicom/public_html/adwinang.com/wp-content/themes/enfold/config-woocommerce/config.php中的非对象上调用成员函数get_cart_subtotal()

这是我在790行的代码:

$cart_subtotal = $woocommerce->cart->get_cart_subtotal();

#1


在尝试访问$ woocommerce对象之前, 听起来你还没有调用全局$ woocommerce;。

更好的方法是使用WC():

$cart_subtotal = WC()->cart->get_cart_subtotal();

或者, 也有可能甚至没有安装和激活WooCommerce …如果是主题依赖项, 请确保执行此操作。


#2


我有一个非常相似的消息。

[25-Sep-2018 10:24:08 UTC] PHP Fatal error:  Uncaught Error: 
Call to a member function get_cart_subtotal() on null in 
themes\storefront\inc\woocommerce\storefront-woocommerce-template-functions.php:80

这是由于我的wp-config.php文件中包含以下内容。

define(‘DOING_CRON’, false);

我在尝试通过激活W3 Total Cache的命令行运行某些内容时添加了这一行。我没有意识到这会完全破坏WooCommerce, 并且直到尝试在我的浏览器中查看网站之前都没有注意到副作用。

赞(0)
未经允许不得转载:srcmini » 在第790行的config-woocommerce/config.php中的非对象上调用成员函数get_cart_subtotal()

评论 抢沙发

评论前必须登录!