Hi,
The mentioned lines calls WooCommerce:
WC()->cart->needs_shipping_address()
I can not tell you why but for some reason, WooCommerce’s cart reporting is not working. Does this also happen if you do not have any plugin activated but WooCommerce+GTM4WP?
Hi,
It hard to replicate the issue.
It sometime happen.
Temporary solution, I will check the condition is_null(WC()->cart)
maybe the same thing
2020-04-23T13:08:31+00:00 CRITICAL Uncaught Error: Call to a member function needs_shipping_address() on null in
/public_html/wp-content/plugins/duracelltomi-google-tag-manager/integration/woocommerce.php:222
Stack trace:
#0 /public_html/wp-includes/class-wp-hook.php(289): gtm4wp_woocommerce_addglobalvars(”)
#1 /public_html/wp-includes/plugin.php(206): WP_Hook->apply_filters(”, Array)
#2 /public_html/wp-content/plugins/duracelltomi-google-tag-manager/public/frontend.php(785): apply_filters(‘gtm4wp_add_glob…’, ”, true)
#3 /public_html/wp-includes/class-wp-hook.php(285): gtm4wp_wp_header_top()
#4 /public_html/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
#5 /public_html/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#6 /public_html/wp-includes/general-template.php(2884): do_action(‘wp_head’)
#7 /public_html/wp-content/themes/mytheme/header.php(21): wp_head()
#8 /public_html в /home/ekoleskh/public_html/wp-content/plugins/duracelltomi-google-tag-manager/integration/woocommerce.php : 222
Maybe its all because like
unset($fields[‘shipping’][‘shipping_address_1’]);
etc billing fields unset?
-
This reply was modified 5 years ago by
dmzw.
@duracelltomi I will try lastest version, thanks
This issue appear when you use a PHP version above 7.2.
I switched to PHP 7.2, until will be fixed, hopefully
@duracelltomi any news regarding this issue?
Hi, I too am seeing the error as recent as 10/28/2020.
Maybe the following details will be helpful:
Wordpress: 5.5.2
WooCommerce: 4.0.0
Google Tag Manager: 1.11.5
2020-10-28T15:34:33+00:00 CRITICAL Uncaught Error: Call to a member function needs_shipping_address() on null in /home/website/public_html/wordpress/wp-content/plugins/duracelltomi-google-tag-manager/integration/woocommerce.php:222
Stack trace:
#0 /home/website/public_html/wordpress/wp-includes/class-wp-hook.php(289): gtm4wp_woocommerce_addglobalvars(”)
#1 /home/website/public_html/wordpress/wp-includes/plugin.php(206): WP_Hook->apply_filters(”, Array)
#2 /home/website/public_html/wordpress/wp-content/plugins/duracelltomi-google-tag-manager/public/frontend.php(785): apply_filters(‘gtm4wp_add_glob…’, ”, true)
#3 /home/website/public_html/wordpress/wp-includes/class-wp-hook.php(285): gtm4wp_wp_header_top()
#4 /home/website/public_html/wordpress/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
#5 /home/website/public_html/wordpress/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#6 /home/website/public_html/wordpress/wp-includes/general-template.php(3006): do_action(‘wp_head’)
#7 in /home/website/public_html/wordpress/wp-content/plugins/duracelltomi-google-tag-manager/integration/woocommerce.php on line 222
Hi,
I am also getting this very regularly.
Fatal error: Uncaught Error: Call to a member function needs_shipping_address() on null in /wp-content/plugins/duracelltomi-google-tag-manager/integration/woocommerce.php:222
Environment:
Google Tag Manager 1.11.5
Woocommerce 4.6.1
Wordpress 5.5.3
PHP 7.3.3
Stack Trace:
1. {anonymous}()
/wp-content/plugins/duracelltomi-google-tag-manager/integration/woocommerce.php:222
2. gtm4wp_woocommerce_addglobalvars('')
/wp-includes/class-wp-hook.php:289
3. WP_Hook->apply_filters('', Array(2))
/wp-includes/plugin.php:206
4. apply_filters('gtm4wp_add_global_vars', '', true)
/wp-content/plugins/duracelltomi-google-tag-manager/public/frontend.php:785
5. gtm4wp_wp_header_top()
/wp-includes/class-wp-hook.php:285
6. WP_Hook->apply_filters(null, Array(1))
/wp-includes/class-wp-hook.php:311
7. WP_Hook->do_action(Array(1))
/wp-includes/plugin.php:478
8. do_action('wp_head')
/wp-includes/general-template.php:3009
9. wp_head()
/wp-content/themes/xxx/header.php:18
10. require_once('/var/www/...')
/wp-includes/template.php:730
11. load_template('/var/www/...', true, Array(0))
/wp-includes/template.php:676
12. locate_template(Array(1), true, true, Array(0))
/wp-includes/general-template.php:48
13. get_header()
/wp-content/themes/xxx/404.php:8
14. include('/var/www/...')
/wp-includes/template-loader.php:106
15. require_once('/var/www/...')
/wp-blog-header.php:19
16. require('/var/www/...')
/index.php:17
Context:
URL : /blogs/wp-json/wp/v2/users/
HTTP Method : GET
HTTP Status : 404
isSSL : Yes
Current Filter : wp_head, gtm4wp_add_global_vars
Hi Everyone,
v1.11.6 includes some fixes that could prevent this exception from being happen again.