<span class="resolved" aria-label="Resolved" title="Topic is resolved."></span>Some fix report

[ad_1]

Replies: 4

Today I was debugging Cartflow setting page not loading. It was caused by:

/wp-json/cartflows/v1/admin/commonsettings/?_locale=use

return 500 error

Fatal error: Uncaught Error: Call to a member function get_cart_contents_count() on null in /home/xxx/public_html/wp-content/plugins/woo-auto-coupons/wac_functions.php:139

Change line 139 from

$cart_qty=$woocommerce->cart->get_cart_contents_count();

to

if ( is_object($woocommerce->cart) ) { $cart_qty=$woocommerce->cart->get_cart_contents_count(); } else {}

fixed the problem but the json format is still not right because

<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/xxx/public_html/wp-content/plugins/woo-auto-coupons/wac_functions.php</b> on line <b>186</b><br />

Change line 186 from

foreach($cart->cart_contents as $cart_item_key=>$cart_item) $cart_items++;

to

foreach((array)$cart->cart_contents as $cart_item_key=>$cart_item) $cart_items++;

I have checked $cart->cart_contents with is_array and is _object, it’s valid, I don’t know why PHP throw out this waring.

Hope this helps somebody who has encountered the same issue.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer