【问题标题】:Call to a member function get_cart_subtotal() on a non-object in config-woocommerce/config.php on line 790在第 790 行的 config-woocommerce/config.php 中的非对象上调用成员函数 get_cart_subtotal()
【发布时间】:2016-02-28 16:24:05
【问题描述】:

我正在尝试登录我的 WordPress 管理面板,但收到以下错误:

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

这是我在第 790 行的代码:

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

【问题讨论】:

    标签: plugins wordpress woocommerce wordpress-theming


    【解决方案1】:

    听起来您在尝试访问$woocommerce 对象之前没有调用global $woocommerce;

    更好的方法是使用WC()

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

    或者,WooCommerce 甚至可能尚未安装和激活...如果它是主题依赖项,请确保这样做。

    【讨论】:

    • 查看我的更新。您是否安装并激活了 WooCommerce?
    • 是的,我也安装并激活了它......该网站运行良好......只是无法进入 WP-admin 区域......这是我的网站adwinang.com
    【解决方案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,并且直到尝试在我的浏览器中查看该网站时才注意到副作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-12
      • 2016-05-24
      • 2015-01-27
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多