I am looking for some help with an issue I have. I have no experience with coding. For my WooCommerce shop, I wanted the shop messages (cart updated and such) to disappear after 6 seconds. I got that to work perfectly with code (using Code Snippets):
add_action( 'wp_head', function () { ?>
<script>
setTimeout(function() {
jQuery('.woocommerce-message, .woocommerce-error').fadeOut('slow')
}, 6000);
</script>
<?php } );
However, on the cart page, it only works 1 time after pushing update cart. How can I fix this or just disable the above script only on this page?
2
Answers
Use setInterval Method instead of timeout because it only runs once.
you need to step of change to make it more clear.
change in
CSS
, and add the following lines in your.css
file:and also, add the following line of
JS
to your header.php or in your .js file:Note:
<script>
and</script>
CSS
section is optional. And I think it makes it make the notification bar looks better.