• Resolved anhduc.bkhn

    (@anhducbkhn)


    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 4 years, 7 months ago by anhduc.bkhn.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    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

    (@anhducbkhn)

    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

    (@duracelltomi)

    I’ve added some additional checks into the core as well:
    https://github.com/duracelltomi/gtm4wp/commit/2e5a75a2ab72ed14a6b5001a3c49a3b58bf22c22

    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 4 years, 7 months ago by dmzw.
    Thread Starter anhduc.bkhn

    (@anhducbkhn)

    @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

    I have the same issue

    @duracelltomi any news regarding this issue?

    adamgonz

    (@adamgonz)

    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

    (@erikmolenaar)

    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

    (@duracelltomi)

    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.