Skip to content

Instantly share code, notes, and snippets.

@swym-public
Last active September 27, 2023 09:57
Show Gist options
  • Save swym-public/de718df188e6a81301471d4da89536d6 to your computer and use it in GitHub Desktop.
Save swym-public/de718df188e6a81301471d4da89536d6 to your computer and use it in GitHub Desktop.
Header filled icon on product add
<script defer>
function renderWishlistHeader(swat) {
var spanElement = document.querySelector(".swym-hidden-counter");
var headerElements = document.querySelectorAll(".swym-wishlist");
if(swat && swat.renderWishlistCount){
swat.renderWishlistCount(spanElement, function(cnt, elem){
headerElements.forEach(function(hElement){
if(cnt == 0){
if(hElement.classList.contains("swym-added-header")){
hElement.classList.remove("swym-added-header");
}
}else{
if (!hElement.classList.contains("swym-added-header")) {
hElement.classList.add("swym-added-header");
}
}
})
});
}
}
if(!window.SwymCallbacks){
window.SwymCallbacks = [];
}
window.SwymCallbacks.push(renderWishlistHeader);
</script>
<style>
a.swym-wishlist.swym-added-header i.icon.icon-swym-wishlist:after {
content: "\f004" !important;
}
/* hide the counter */
.swym-hidden-counter {
display: none;
}
</style>
@gopibswym
Copy link

Add this style to show wishlist header heart icon even when wishlist is empty count
i.icon.icon-swym-wishlist:after { content: "" !important; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment