在Woocommerce中,我有一个简单的函数可以返回购物车项目,当我在function.php中调用此函数时,我会出错。
<?php
class Theme {
public static $version;
function __construct() {
$theme = wp_get_theme();
self::$version = $theme['Version'];
$this->cart_items();
}
function cart_items(){
var_dump(get_users());
}
new Theme();
我有这个错误:
致命错误:未捕获错误:调用成员函数get_cart_contents()为空
答案 0 :(得分:0)
Please add this below code
<?php
class Theme {
public static $version;
function __construct() {
$theme = wp_get_theme();
self::$version = $theme['Version'];
$this->cart_items();
}
function cart_items(){
var_dump(get_users());
}
}
new Theme();