Title: error: &#8220;Call to a member function needs_shipping_address() on null&#8221;
Last modified: April 13, 2020

---

# error: “Call to a member function needs_shipping_address() on null”

 *  Resolved [anhduc.bkhn](https://wordpress.org/support/users/anhducbkhn/)
 * (@anhducbkhn)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/error-1330/)
 * My Env:
 * – WP: 5.3.2
    – WC: 3.8.1 – Google Tag Manager for WordPress: 1.11.4 – PHP: 7.2.1–
   Mysql: 5.6
 * I got this error message:
    “2020/04/09 07:54:52 [error] 14#14: *20182 FastCGI
   sent in stderr: “PHP message: PHP Fatal error: Uncaught Error: Call to a member
   function needs_shipping_address() on null in /var/www/wp-content/plugins/duracelltomi-
   google-tag-manager/integration/woocommerce.php:222”
 * Please help!
    -  This topic was modified 6 years, 3 months ago by [anhduc.bkhn](https://wordpress.org/support/users/anhducbkhn/).

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [Thomas Geiger](https://wordpress.org/support/users/duracelltomi/)
 * (@duracelltomi)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/error-1330/#post-12672687)
 * 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?
 *  Thread Starter [anhduc.bkhn](https://wordpress.org/support/users/anhducbkhn/)
 * (@anhducbkhn)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/error-1330/#post-12681309)
 * Hi,
 * It hard to replicate the issue.
 * It sometime happen.
 * Temporary solution, I will check the condition is_null(WC()->cart)
 *  Plugin Author [Thomas Geiger](https://wordpress.org/support/users/duracelltomi/)
 * (@duracelltomi)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/error-1330/#post-12696517)
 * I’ve added some additional checks into the core as well:
    [https://github.com/duracelltomi/gtm4wp/commit/2e5a75a2ab72ed14a6b5001a3c49a3b58bf22c22](https://github.com/duracelltomi/gtm4wp/commit/2e5a75a2ab72ed14a6b5001a3c49a3b58bf22c22)
 *  [dmzw](https://wordpress.org/support/users/dmzw/)
 * (@dmzw)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/error-1330/#post-12720834)
 * 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 6 years, 3 months ago by [dmzw](https://wordpress.org/support/users/dmzw/).
 *  Thread Starter [anhduc.bkhn](https://wordpress.org/support/users/anhducbkhn/)
 * (@anhducbkhn)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/error-1330/#post-12723052)
 * [@duracelltomi](https://wordpress.org/support/users/duracelltomi/) I will try
   lastest version, thanks
 *  [milleniumrom](https://wordpress.org/support/users/milleniumrom/)
 * (@milleniumrom)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/error-1330/#post-13383790)
 * This issue appear when you use a PHP version above 7.2.
 * I switched to PHP 7.2, until will be fixed, hopefully
 *  [JohnS0N](https://wordpress.org/support/users/johns0n/)
 * (@johns0n)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/error-1330/#post-13499439)
 * I have the same issue
 *  [JohnS0N](https://wordpress.org/support/users/johns0n/)
 * (@johns0n)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/error-1330/#post-13519283)
 * [@duracelltomi](https://wordpress.org/support/users/duracelltomi/) any news regarding
   this issue?
 *  [adamgonz](https://wordpress.org/support/users/adamgonz/)
 * (@adamgonz)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/error-1330/#post-13603378)
 * 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
 *  [Erik Molenaar](https://wordpress.org/support/users/erikmolenaar/)
 * (@erikmolenaar)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/error-1330/#post-13624446)
 * 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
       ```
   
 *  Plugin Author [Thomas Geiger](https://wordpress.org/support/users/duracelltomi/)
 * (@duracelltomi)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/error-1330/#post-13726425)
 * Hi Everyone,
 * v1.11.6 includes some fixes that could prevent this exception from being happen
   again.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘error: “Call to a member function needs_shipping_address() on null”’ 
is closed to new replies.

 * ![](https://ps.w.org/duracelltomi-google-tag-manager/assets/icon-256x256.png?
   rev=1708451)
 * [GTM4WP - A Google Tag Manager (GTM) plugin for WordPress](https://wordpress.org/plugins/duracelltomi-google-tag-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/duracelltomi-google-tag-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/duracelltomi-google-tag-manager/reviews/)

 * 11 replies
 * 7 participants
 * Last reply from: [Thomas Geiger](https://wordpress.org/support/users/duracelltomi/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/error-1330/#post-13726425)
 * Status: resolved