• Resolved mrfedor

    (@mrfedor)


    This error appears periodically in the woocommerce logs. With what it can be connected?

    2023-10-19T15:40:52+00:00 CRITICAL Uncaught Error: Call to a member function get_token() on null in /var/www/html/wp-content/plugins/woocommerce-square/includes/Framework/PaymentGateway/Payment_Gateway_Direct.php:574 Stack trace: #0 /var/www/html/wp-content/plugins/woocommerce-square/includes/Gateway.php(334): WooCommerce\Square\Framework\PaymentGateway\Payment_Gateway_Direct->get_order() #1 /var/www/html/wp-content/plugins/woocommerce-square/includes/Framework/PaymentGateway/Payment_Gateway_Direct.php(280): WooCommerce\Square\Gateway->get_order() #2 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1050): WooCommerce\Square\Framework\PaymentGateway\Payment_Gateway_Direct->process_payment() #3 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-checkout.php(1279): WC_Checkout->process_order_payment() #4 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(508): WC_Checkout->process_checkout() #5 /var/www/html/wp-includes/class-wp-hook.php(310): WC_AJAX::checkout() #6 /var/www/html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters() #7 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action() #8 /var/www/html/wp-content/plugins/woocommerce/includes/class-wc-ajax.php(96): do_action() #9 /var/www/html/wp-includes/class-wp-hook.php(310): WC_AJAX::do_wc_ajax() #10 /var/www/html/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters() #11 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action() #12 /var/www/html/wp-includes/template-loader.php(13): do_action() #13 /var/www/html/wp-blog-header.php(19): require_once(‘…’) #14 /var/www/html/index.php(17): require(‘…’) #15 {main} thrown in /var/www/html/wp-content/plugins/woocommerce-square/includes/Framework/PaymentGateway/Payment_Gateway_Direct.php on line 574

    Ver. wp – 6.3.2

    Ver. woocommerce – 8.2.1

    Ver. Squre – 4.2.2

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @mrfedor,

    From what I understand, you’re dealing with a recurring “CRITICAL Uncaught Error: Call to a member function get_token()” in your WooCommerce logs. Thanks for sharing the details about the error, as well as the versions of WordPress, WooCommerce, and Square you’re using.

    This error typically pops up when a function attempts to call a method on an object that either doesn’t exist or is null. In your case, it seems that the get_token() method is trying to call on a null object within the WooCommerce Square plugin.

    Here’s how you can tackle this issue:

    1. Update Plugins and Themes: Make sure all your plugins and themes are up-to-date. An outdated plugin or theme might cause compatibility issues.
    2. Plugin Conflict: Try disabling all plugins except WooCommerce and WooCommerce Square to see if the error still shows up. If it disappears, turn the plugins back on one at a time to identify the conflicting one.
    3. Theme Conflict: Try switching to a default theme like Storefront to see if the issue persists. If it doesn’t, your current theme might be the issue. Here’s a handy guide on how to test for conflicts: 👉 How to Test for Plugin and Theme Conflicts.
    4. Turn on Debugging: If the issue persists, turn on debugging in WordPress. This can help you identify the problem. Add these lines to your wp-config.php file:
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );
    @ini_set( 'display_errors', 0 );

    This will create a debug.log file in your wp-content directory, logging any PHP errors or notices. For a more detailed guide on enabling debugging in WordPress, you can visit this link: 👉 Debugging in WordPress

    If the issue continues after trying these steps, please share more details, like the exact error messages you see when debug mode is on. This will help us identify and solve the problem more effectively.

    Additionally, sharing your site’s System Status report would be helpful. It will give us a better understanding of your site’s setup and help us pinpoint the problem. You can find it via WooCommerce > Status. Select Get system report and then Copy for support.

    Once you’ve gathered this information, please paste it inside a Code block in your reply, or use https://pastebin.com to paste it and share the link with us.

    Thanks for your patience and cooperation in this matter! We’re here to help you get this sorted.

    Thread Starter mrfedor

    (@mrfedor)

    Hello! Plugins have been updated.
    Unfortunately, we cannot disable plugins for the production version.
    The working version does not reproduce the error. Including because of the dev mode of the square plugin.
    On the production version, the debug mode is turned on; time is needed to collect information.

    The square plugin error appears unstable. It takes some time for it to reproduce. Maybe you can tell me what could be causing it?

    If you pay attention to the logs above, the errors are related to Ajax in checkout.

    Hi @mrfedor,

    Thank you for your response and for updating the plugins. I understand your concern about disabling plugins on the production version of your site. In such cases, we recommend using the Health Check and Troubleshooting plugin. This plugin allows you to go into a troubleshooting mode where all plugins are deactivated and the theme is switched to a default one, but these changes are only visible to you. Your customers will continue to see the regular site.

    Here is the link to download the plugin: 👉 Health Check and Troubleshooting.

    After installing and activating the plugin, you can access the troubleshooting mode by going to ‘WP-Admin > Tools > Site Health > Troubleshooting‘. From there, you can enable plugins one by one to identify if there’s a conflict causing the error.

    Here’s an image for reference:

    Image Link: https://snipboard.io/H3dfmx.jpg

    Regarding the AJAX-related errors in the checkout, this could be due to a conflict with another plugin or theme that is improperly using AJAX calls, or there might be an issue with the server configuration.

    Once you’ve gathered more information from the debug mode and the Health Check plugin, please share it with us. This will help us to better understand the issue and provide a more accurate solution.

    We appreciate your patience and cooperation in this matter. We’re here to help you get this sorted out.

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

The topic ‘CRITICAL Uncaught Error: Call to a member function get_token()’ is closed to new replies.