Error: wp is not defined
-
Having an error pop in my dev console. Tried for hours to resolve it. Also asked ai and google for solutions to no avail.
It says its errors on checkout and funny thing is im using Turnstile on cf7 forms to avoid spam emails and signups, with turnstile turned off on checkouts (tested w it enabled for check out and did not resolve either)
path having the issue is in this plugin-/wp-content/plugins/simple-cloudflare-turnstile/js/integrations/woocommerce.js
/* Woo Checkout / jQuery( document ).ready(function() { jQuery( document.body ).on( ‘update_checkout updated_checkout applied_coupon_in_checkout removed_coupon_in_checkout’, function() { if(jQuery(‘#cf-turnstile-woo-checkout’).is(‘:empty’)) { turnstileWooCheckoutReset(); } }); jQuery( document.body ).on( ‘checkout_error’, turnstileWooCheckoutReset); }); function turnstileWooCheckoutReset() { if(document.getElementById(‘cf-turnstile-woo-checkout’)) { turnstile.remove(‘#cf-turnstile-woo-checkout’); turnstile.render(‘#cf-turnstile-woo-checkout’); } } / On click “.checkout .showlogin” link re-render */
jQuery(‘.showlogin’).on(‘click’, function() {
turnstile.remove(‘.sct-woocommerce-login’);
turnstile.render(‘.sct-woocommerce-login’);
});/* Woo Checkout Block */
if ( wp && wp.data && turnstile ) {
var unsubscribe = wp.data.subscribe(function() {
const turnstileItem = document.getElementById(‘cf-turnstile-woo-checkout’);
if(turnstileItem) {
turnstile.render(turnstileItem, {
sitekey: turnstileItem.dataset.sitekey,
callback: function(data) {
wp.data.dispatch(‘wc/store/checkout’).__internalSetExtensionData(‘simple-cloudflare-turnstile’, {
token: data
})
}
});turnstile.onEx unsubscribe(); } }, 'wc/store/cart');}
I disabled rocket loader w cloudflare did not resolve.
The page I need help with: [log in to see the link]
The topic ‘Error: wp is not defined’ is closed to new replies.