Created
June 10, 2022 12:49
-
-
Save dislokacia/1b1b171b4c0f3cfa021c948ba82bbee2 to your computer and use it in GitHub Desktop.
Hide element, if there are no products in the cart (with Ajax events )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.empty_message { | |
display: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function( $ ){ | |
$( document ).ajaxComplete(function() { | |
if (!Cookies.get('woocommerce_items_in_cart')) { | |
$('.empty_message').show(); | |
} else { | |
$('.empty_message').hide(); | |
} | |
}); | |
if (!Cookies.get('woocommerce_items_in_cart')) { | |
$('.empty_message').show(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the class 'empty_message' to the element you want to hide
https://gyazo.com/2c93eb1344ad8cda0ecdbea8ba7c5f71