Skip to content

Commit 7f0f1f7

Browse files
committed
Add wishlist counter to top links
1 parent 4c29f8e commit 7f0f1f7

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

view/frontend/templates/script/component/top-links.phtml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ $customerAccountLoginUrl = $block->getUrl('customer/account/login');
2121
this.showCustomerUrls();
2222
this.hideGuestUrls();
2323
this.showGreeting();
24+
this.showWishlistText();
2425
} else {
2526
this.hideCustomerUrls();
2627
this.showGuestUrls();
@@ -64,6 +65,19 @@ $customerAccountLoginUrl = $block->getUrl('customer/account/login');
6465
element.style.display = 'none';
6566
}
6667
},
68+
showWishlistText() {
69+
const element = this.$el.querySelector('.link.wishlist span.counter');
70+
if (!element) {
71+
return;
72+
}
73+
74+
const wishlistSection = Alpine.store('LokiLocalStorage').get('wishlist');
75+
if (!wishlistSection) {
76+
return;
77+
}
78+
79+
element.innerHTML = wishlistSection.counter;
80+
},
6781
getGuestElements() {
6882
return [
6983
this.$el.querySelector('a[href="<?= /* @noEscape */ $customerAccountLoginUrl ?>"]')

0 commit comments

Comments
 (0)