0

I have a peice of code that I know works where I set the pointer events for the shopping cart icon dependant on what page the user is on:

add_action('posts_selection', 'check_cart_checkout_page');

function check_cart_checkout_page(){
if(is_cart() || is_checkout()){ 
    echo '<style>.ast-header-woo-cart { pointer-events:none;}</style>';
}
else{
    echo '<style>.ast-header-woo-cart { pointer-events:auto;}</style>';
}
}

However I noticed that when this code snippet is activated, it causes the order summary block to be stuck on spinner loader (see image below). Not sure why this is? I deactivated all other code snippets and it's this code that's causing it. Priority of this snippet is 10.

enter image description here

BruceyBandit
  • 3,978
  • 19
  • 72
  • 144
  • did u check the console for javascript errors? because it doesn't seem to be a correct javascript syntax – Flash Thunder Apr 18 '21 at 10:00
  • Yes I did check and there is no console errors. I activate the code so you can see it yourself: https://puffpastrydelights.com/ – BruceyBandit Apr 18 '21 at 10:01
  • I checked myself and it works for me without any problems. – Flash Thunder Apr 18 '21 at 11:41
  • @FlashThunder That's because I had an idea and trying to find a solution. I got it so it doesn't load the spinner but the pointer events doesn't work. If I remove the add action then the cart stops spinning but the pointer doesn't work as expected. If I keep the add action, then the spinner stays on. Let me edit my question with latest code so you can see – BruceyBandit Apr 18 '21 at 11:46
  • If you try now, you will see it's broken with the spinner as I added the action back in. The. code currently resembles the one I just posted in question. I think I need that add action because of this: https://docs.woocommerce.com/document/conditional-tags/ – BruceyBandit Apr 18 '21 at 11:48
  • Use instead `wp_head` hook with a priority of 1000 for example… – LoicTheAztec Apr 18 '21 at 13:25

0 Answers0