Home
Wiki
Home
Wiki
  1. 3. Reusables
  • Back to home
  • 1. Themes
  • Vs Code
    • Getting Started
  • Kitchenware
    • Layout
      • New Layout
      • Legacy Layout
    • Components
      • Announcement
      • Banner Carousel
      • Banner With Products Carousel
      • Blog Category List
      • Blog List
      • Brand List
      • Brands Carousel
      • Breadcrumb
      • Call To Action
      • Cart
      • Categories List
      • Change Password
      • Checkout
      • Cookie Manager
      • Filter list
      • Footer
      • Forgot Password
      • Form
      • Hero Carousel
      • Icon Block
      • Invitation
      • Last Visited Products
      • Layout
      • Login
      • Map
      • Nav Bar
      • Offer
      • Product Attachments
      • Product Attributes
      • Product Documentation
      • Product Expected
      • Product Modal
      • Products Block
      • Products Carousel
      • Product Single
      • Profile
      • Quote
      • Register
      • Related Products
      • Search
      • Stores
      • Subscribe Newsletter
      • Text with Image
      • Top Bar
      • Video
    • Reusables
      • Getting Started
    • Assets
      • Getting Started
    • SDK
      • Products
        • _findProductsByCategory
        • _findProductsByIds
        • _findProductsByTitle
        • _findProductsByFilter
        • _findProductsByCriteria
        • _findProductsAndCalculate
        • _findProductsThenCalculate
        • _getProductAttributeSet
        • _setLastVisited
      • Categories
        • _findCategoryTreeById
        • _findCategoriesByIds
        • _findCategoryByAlias
        • _findCategoryTreeByAlias
        • _getCategoryContent
      • Collections
        • _getCollectionContent
        • _findCollectionsByIds
        • _findCollectionsByIdsThenCalculate
      • Brands
        • _getBrandContent
        • _findBrandsByIds
      • Cart
        • _addToCartMulti
        • _addToCart
        • _setCart
        • _clearCart
        • _setCartListener
        • _removeFromCart
        • _calculateCart
      • Checkout
        • _startCheckout
        • _updateCheckout
        • _completeCheckout
      • Shopping Lists
        • _getShoppingLists
        • _updateShoppingList
        • _createShoppingList
        • _deleteShoppingList
        • _getShoppingListByAlias
      • Navigation
        • _getFooterMenu
        • _getHeaderMenu
      • Users
        • _getUserById
      • Utils
        • _calculateCurrency
        • _getCurrencySymbol
        • _getCulture
        • _subscribeToNewsletter
        • _findUnitsByIds
  • Noir
    • 0. Introduction
    • 1. Structure
      • Overview
      • LayoutA.liquid
      • ComponentsList.liquid
      • Metas.liquid
      • CssVariables.liquid
      • Json.liquid
      • GoogleTagManager.liquid
      • StagingButton.liquid
    • 2. Components
      • Overview
      • Announcement
      • BannerCarousel
      • BlogCategoryList
      • BlogList
      • BrandList
      • Breadcrumb
      • Cart
      • CategoriesList
      • ChangePassword
      • Checkout
      • CookieManager
      • FilterList
      • Footer
      • ForgotPassword
      • Form
      • IconBlock
      • Invitation
      • LastVisitedProducts
      • Login
      • Map
      • NavBar
      • ProductAttachments
      • ProductAttributes
      • ProductComparison
      • ProductDocumentation
      • ProductMixList
      • ProductsBlock
      • ProductsCarousel
      • ProductSingle
      • Profile
      • Register
      • RelatedProducts
      • SingleBlog
      • Stores
      • TextWithImage
      • ThankYouPage
      • TopBar
      • Wishlist
    • 3. Reusables
      • Overview
      • Addresses
      • BillingRetail
      • AddressForm
      • AnnouncementModal
      • BackToTop
      • Company
      • General
      • Login
      • LoginModal
      • Orders
      • Payment
      • ProductAttachments
      • ProductAttributes
      • ProductComparisonButton
      • ProductComparisonFloatingButton
      • ProductGridItem
      • ProductListItem
      • ShoppingListsButton
      • ProductModal
      • ProfileInfo
      • PromptModal
      • Register
      • Shipping
      • ShoppingLists
      • ShoppingListsNavbar
      • Toast
      • Users
      • VariantContent
      • WishlistButton
      • Services
    • 4. Assets
      • Fonts
      • Images
      • Templates
      • Javascript
        • Overview
        • theme.js
      • Css / Scss
        • Overview
        • ThemeClasses
    • 5. SDK
      • Overview
      • LiquidGlobals
      • ServicesSDK
  1. 3. Reusables

WishlistButton

Purpose#

The WishlistButton reusable renders a toggle button that adds/removes a product from the user’s wishlist.
It delegates the actual state management and API calls to the global Alpine store $store.wishlist (defined in Assets/js/theme.js).

Where it's rendered#

This reusable is rendered from product cards and product pages, for example:
Reusables/ProductGridItem/Default.liquid
Reusables/ProductListItem/Default.liquid
Components/ProductSingle/Default.liquid
Typical render call:
{% render 'Reusables\\WishlistButton\\Default', id: product.id, title: product.title %}

Inputs (Liquid render parameters)#

Named parameters:
id
Product id used as the wishlist key.
title
Human-readable product title used for the button title / aria-label.

Template behavior (Liquid + Alpine)#

Rendering is gated by the feature flag:
GlobalData.Settings.EnableWishlist
The template uses Alpine store bindings (no JS factory):
Active state:
:class="{'active': $store.wishlist.isInWishlist('<id>') }"
Click handler:
@click.stop.prevent="$store.wishlist.toggle('<id>', removeErrorMessage, addErrorMessage)"
The button title / aria-label changes depending on whether the product is already in the wishlist.

Data contract (JS runtime)#

This reusable is store-driven. The runtime contract is the existence of $store.wishlist with these methods:
isInWishlist(id)
toggle(id, removeFromWishlistErrorMessage, addToWishlistErrorMessage)
It also depends on the following browser state:
Cookie: wishlist
Parsed by $store.wishlist.readWishlistIds().
Cross-tab sync:
LocalStorage key: wishlistSync
DOM event: wishlistUpdated

JavaScript#

Global object#

Global object: wishlistbuttonreusabledefault
Notes:
It is currently an empty object ({}) and is not referenced by the Liquid template.
The real logic is implemented in the Alpine store $store.wishlist in Assets/js/theme.js.

Global Alpine stores#

$store.wishlist#

What it represents
A client-side cache of wishlist product ids (items: string[]).
How this reusable uses it
Reads isInWishlist(id) to render active state and accessible labels.
Calls toggle(...) on click.
Practical impact
If window.showWishlist is false (set in Structure/LayoutA.liquid), the store is not created and the reusable is not rendered.

Services / API calls#

The reusable itself does not call APIs, but $store.wishlist.toggle(...) calls:
servicesreusabledefault.addItemToWishlist(id)
servicesreusabledefault.removeItemFromWishlist(id)
On failure it shows toast errors via $store.toast.

Dependencies#

Liquid: Reusables/WishlistButton/Default.liquid
Translations: Reusables/WishlistButton/Default.json
Feature flag: GlobalData.Settings.EnableWishlist
Alpine store: $store.wishlist (defined in Assets/js/theme.js)
Alpine store: $store.toast (used by $store.wishlist)
SDK wrapper: servicesreusabledefault.addItemToWishlist(...), servicesreusabledefault.removeItemFromWishlist(...)

Notes#

The button is purely a UI trigger; the wishlist contract lives in $store.wishlist.
The store reads wishlist ids from the wishlist cookie and builds the list differently depending on authentication (window.userAuthenticated, window.userId).
Modified at 2026-04-14 13:18:56
Previous
VariantContent
Next
Services
Built with