CryptoWoo is not defined
-
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.
-
This topic was modified 6 months, 2 weeks ago by
-
Hi there,
Thanks for reporting the issue! The error
Uncaught ReferenceError: CryptoWoo is not definedtypically means that theCryptoWooJavaScript object (which is added usingwp_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:
- View Page Source
On the/checkout/order-paypage, right-click and choose “View Page Source,” then search forvar CryptoWoo =. This line should appear before thepolling.jsscript is loaded. - 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. - 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. - 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!
Thanks for the prompt reply, unfortunately none of the solutions work.
- In the source code there is no “CryptoWoo =”
- 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.
- Tried with Twenty Twenty-Four
- Tried in new incognito window, the site is still on local server there is no CDN yet.
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’,…) ?Thanks again for the detailed reply — this is a bit puzzling, since I’ve confirmed that the
wp_enqueue_scriptsaction (where the script is registered) runs beforewoocommerce_receipt_cryptowoo(where the script is localized and enqueued). That meanswp_register_script()should always run beforewp_localize_script(), and theCryptoWooobject 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_cryptowooearlier than expected — possibly from a custom function, plugin, or some custom logic.To dig deeper, you can add the following code to your
functions.phpfile. 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-paypage and check yourwp-content/debug.logfile. 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!
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_cryptowooaction runs beforewp_enqueue_scripts. This means our script is being enqueued before it’s registered, which leads to theCryptoWooJavaScript 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_scriptsruns 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!
Thanks for your time Olav, I am glad we found the issue.
- View Page Source
The topic ‘CryptoWoo is not defined’ is closed to new replies.