In Woocommerce I have a simple function which return cart items and when I call this function in function.php I have an error .
<?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();
And I have this error:
Fatal error: Uncaught Error: Call to a member function get_cart_contents() on null
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.