• Resolved cholakovdev

    (@cholakovdev)


    Hi, in the checkout/order-pay page i get following js error:

    Uncaught ReferenceError: CryptoWoo is not defined
    at HTMLDocument. (polling.js?ver=1.6.12:159:39)

    How it is defined, can you help me solve this issue?

    • This topic was modified 6 months, 2 weeks ago by cholakovdev.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Olav Småriset

    (@olsm)

    Hi there,

    Thanks for reporting the issue! The error Uncaught ReferenceError: CryptoWoo is not defined typically means that the CryptoWoo JavaScript object (which is added using wp_localize_script) is not available in the browser when the script runs.

    We’ve double-checked the code and confirmed that everything is working as expected, so this is likely something specific to your site’s setup.

    Here are a few things you can check on your end:

    1. View Page Source
      On the /checkout/order-pay page, right-click and choose “View Page Source,” then search for var CryptoWoo =. This line should appear before the polling.js script is loaded.
    2. Caching or Optimization Plugins
      If you’re using any caching, minification, or JavaScript optimization plugins (like Autoptimize, WP Rocket, or LiteSpeed Cache), try disabling them temporarily. These tools can sometimes load the script before the localized variables are printed, causing this error.
    3. Theme or Plugin Conflicts
      Try switching to a default theme (like Twenty Twenty-Four) and disabling other plugins to see if something is interfering with script loading.
    4. Clear Browser and Site Cache
      Clear your browser cache, as well as any server or CDN-level caches you may be using. You can also try loading the page in an incognito window or on another device.

    Let us know what you find after these steps — we’re happy to help further if needed!

    Thread Starter cholakovdev

    (@cholakovdev)

    Thanks for the prompt reply, unfortunately none of the solutions work.

    1. In the source code there is no “CryptoWoo =”
    2. We don’t use any caching plugins, only WordPress 6.7.2, WooCommerce 9.8.1, CryptoWoo 1.6.12, Redux Framework 4.5.7 and the default theme Twenty Twenty-Five.
    3. Tried with Twenty Twenty-Four
    4. Tried in new incognito window, the site is still on local server there is no CDN yet.
    Thread Starter cholakovdev

    (@cholakovdev)

    I debug that
    wp_localize_script( ‘cw_polling’, ‘CryptoWoo’, $php_vars_array );
    is called before
    cw_register_script( ‘cw_polling’, CWOO_PLUGIN_PATH . ‘assets/js/polling.js’, array( ‘jquery’ ) );

    which answer why it is missing.
    The question is why wp_localize_script( ‘cw_polling’,…) is loaded before cw_register_script( ‘cw_polling’,…) ?

    Plugin Contributor Olav Småriset

    (@olsm)

    Thanks again for the detailed reply — this is a bit puzzling, since I’ve confirmed that the wp_enqueue_scripts action (where the script is registered) runs before woocommerce_receipt_cryptowoo (where the script is localized and enqueued). That means wp_register_script() should always run before wp_localize_script(), and the CryptoWoo object should be available.

    Since this issue does not occur on my end and has not been reported by anyone else, it seems likely that something in your local setup is firing woocommerce_receipt_cryptowoo earlier than expected — possibly from a custom function, plugin, or some custom logic.

    To dig deeper, you can add the following code to your functions.php file. It will log when each action is fired and include a full backtrace, so we can see exactly where and when these functions are being triggered:

    add_action( 'woocommerce_receipt_cryptowoo', function() {
    	error_log( "--- woocommerce_receipt_cryptowoo fired ---" );
    	error_log( print_r( debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), true ) );
    } );
    
    add_action( 'wp_enqueue_scripts', function() {
    	error_log( "--- wp_enqueue_scripts fired ---" );
    	error_log( print_r( debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), true ) );
    }, 10 );
    

    Then reload the checkout/order-pay page and check your wp-content/debug.log file. You should see the order in which the actions are firing, and what triggered them.

    Let me know what it shows and we’ll figure it out from there!

    Plugin Contributor Olav Småriset

    (@olsm)

    Thanks for your patience — I’ve investigated the issue and was able to reproduce it using the Twenty Twenty-Five theme (a block-based Full Site Editing theme).

    The root cause is that in block-based themes, the woocommerce_receipt_cryptowoo action runs before wp_enqueue_scripts. This means our script is being enqueued before it’s registered, which leads to the CryptoWoo JavaScript object being undefined and causes the error you’re seeing on the order receipt page.

    This order of execution is different from classic themes, where wp_enqueue_scripts runs earlier and things work as expected. Until we’ve updated the plugin to handle this case properly, we recommend using a non-block-based theme as a workaround.

    Thanks again for reporting this!

    Thread Starter cholakovdev

    (@cholakovdev)

    Thanks for your time Olav, I am glad we found the issue.

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

The topic ‘CryptoWoo is not defined’ is closed to new replies.