Support » Plugin: WooCommerce UPS Shipping – Live Rates and Access Points » PHP Fatal error: Uncaught Error: Call to undefined function wc_empty_cart()

  • Resolved devbd

    (@devbd)


    Hi, I struggle with the following error which seems to be triggered by your plugin:

    PHP Fatal error: Uncaught Error: Call to undefined function wc_empty_cart() in /wp-content/plugins/woocommerce/includes/class-wc-session-handler.php:372\nStack trace:\n#0 /wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(363): WC_Session_Handler->forget_session()\n#1 /wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(99): WC_Session_Handler->destroy_session()\n#2 /wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(71): WC_Session_Handler->init_session_cookie()\n#3 /wp-content/plugins/woocommerce/includes/class-woocommerce.php(825): WC_Session_Handler->init()\n#4 /wp-content/plugins/flexible-shipping-ups/src/Plugin/Plugin.php(275): WooCommerce->initialize_session()\n#5 /wp-includes/class-wp-hook.php(307): WPDesk\\FlexibleShippingUps\\Plugin->init_ups_access_points(”)\n#6 /wp-includes in /wp-content/plugins/woocommerce/includes/class-wc-session-handler.php on line 372, referer: /wp-admin/edit.php?post_type=shop_order

    I understand the error is being triggered by init_ups_access_points() function that runs WC()->initialize_session(); in your plugin. This ends up in calling WC_Session_Handler->forget_session() which calls wc_empty_cart() that doesn’t exist at the moment of making the call.

    I was unable to recreate this problem when logging in via /wp-admin or via accessing /wp-admin/edit.php?post_type=shop_order when both logged and unlogged, yet the error is being triggered from time to time.

    I completed all the troubleshooting checks from this post https://wordpress.org/support/topic/troubleshooting-please-read-before-posting/ and everything is set up correctly.

    Finally, both plugins (UPS shipping and WooCommerce) are updated to the newest version. WP core is also updated.

    Could you support me with the error, please? Thank you for any advice,

    Regards,
    Karolina

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor grola

    (@grola)

    Hi,

    looks like a conflict with another plugin. Please, deactivate other plugins one at a time and let us know which plugin is conflicting.

    Best regards
    Grzegorz

    Thread Starter devbd

    (@devbd)

    Hi Grzegorz,

    Thank you for your advice. The problem is that we are unaware of what action triggers the error (we couldn’t recreate the error ourselves). Therefore, we can’t prepare any reliable test to see if deactivating a particular plugin solves the issue. We only see in our logs that error is getting logged from time to time.

    For this reason, we can’t deactivate other plugins, as we would need to keep them deactivated for a quite a long time which in most cases would have an impact on the functionality of the website.

    The only plugin we could deactivate at this stage is the one responsible for caching. I’ll deactivate this one, wait a few days and update you if it was responsible.

    Regards,
    Karolina

    I’m getting the same error. It’s not happening for me but my client is reporting it and I got the automated WooCommerce error email. He got it after clicking the confirmation link in the “New Admin Email Address” email.

    An error of type E_ERROR was caused in line 372 of the file /public/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php. Error message: Uncaught Error: Call to undefined function wc_empty_cart() in /public/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php:372
    Stack trace:
    #0 /public/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(363): WC_Session_Handler->forget_session()
    #1 /public/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(99): WC_Session_Handler->destroy_session()
    #2 /public/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(71): WC_Session_Handler->init_session_cookie()
    #3 /public/wp-content/plugins/woocommerce/includes/class-woocommerce.php(825): WC_Session_Handler->init()
    #4 /public/wp-content/plugins/flexible-shipping-ups/src/Plugin/Plugin.php(275): WooCommerce->initialize_session()
    #5 /public/wp-includes/class-wp-hook.php(307): WPDesk\FlexibleShippingUps\Plugin->init_ups_access_points('')
    #6 /public/wp-includes/class-w
    Plugin Contributor grola

    (@grola)

    @jtphelan @devbd thank you for the details. It will be fixed in the next version.

    Grzegorz

    Plugin Contributor grola

    (@grola)

    @devbd @jtphelan new version with hotfix available.

    Best regards
    Grzegorz

    Where is the new version? I just received the same error too.

    Plugin Support Wojciech Pyrgies

    (@wojtekpyrgies)

    Hi @kbdiverservices,
    The new version of the plugin with a hotfix is 1.17.8. If you navigate to Plugins > Installed plugins, you should see a notice under the plugin name about a possible update.

    Please let me know if you still get the same error with version 1.17.8.

    Kind regards,

    Plugin Support lusp

    (@lusp)

    Since there are no further inquiries concerning this case I’m marking this thread as resolved.

    Kind regards,
    Luke

    I got the same thing:

    Ultimate Member Version 2.4.2 installed.I had updated about 45 min ago and I got the same thing , errors are in woo commerence:
    WooCommerce (version 6.7.0): – when I disabled Ultimate Member ,everything worked fine.
    
    An error of type E_ERROR was caused in line 372 of the file /home4/NAMEOFWEBISTENOTDISCLOSED/public_html/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php. Error message: Uncaught Error: Call to undefined function wc_empty_cart() in /home4/NAMEOFWEBISTENOTDISCLOSED/public_html/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php:372
    Stack trace:
    #0 /home4/NAMEOFWEBISTENOTDISCLOSED/public_html/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(363): WC_Session_Handler->forget_session()
    #1 /home4/NAMEOFWEBISTENOTDISCLOSED/public_html/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(99): WC_Session_Handler->destroy_session()
    #2 /home4/NAMEOFWEBISTENOTDISCLOSED/public_html/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(71): WC_Session_Handler->init_session_cookie()
    #3 /home4/NAMEOFWEBISTENOTDISCLOSED/public_html/wp-content/plugins/woocommerce/includes/class-woocommerce.php(861): WC_Session_Handler->init()
    #4 /home4/NAMEOFWEBISTENOTDISCLOSED/public_html/wp-content/plugins/woocommerce-payments/includes/class-wc-payments-fraud-service.php(131): WooCommerce->initialize_session()
    #5 /home4/NAMEOFWEBISTENOTDISCLOSED/public_html/wp-content/plugins/woocommerce-payments/includes/class-wc-payments-fraud-service.php(152): WC_Payments

    Okay – I experimented : I deactivated WooCommerence Memberships and reactived Ultimate Member so far everything is working fine.

    We are getting same type issue

    #0 /home/customer/www/***.uk.com/public_html/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(363): WC_Session_Handler->forget_session()
    #1 /home/customer/www/***.uk.com/public_html/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(99): WC_Session_Handler->destroy_session()
    #2 /home/customer/www/***.uk.com/public_html/wp-content/plugins/woocommerce/includes/class-wc-session-handler.php(71): WC_Session_Handler->init_session_cookie()
    #3 /home/customer/www/***.uk.com/public_html/wp-content/plugins/woocommerce/includes/class-woocommerce.php(861): WC_Session_Handler->init()
Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.