loveful-wishlist snippet render them for you, and you can write any of them into your own theme code: a section, a product card, a quick view, a custom header. For the bus they all talk to, see JavaScript API.
How the elements work
- They upgrade wherever they appear. Each element sets itself up when it’s added to the page, so markup added later (a quick view, a filtered collection grid, a section re-rendered by the theme editor) works with no extra code. Removing an element removes its listeners.
- They share one state. Every element follows
window.loveful, so a save in one place updates every button, count and list on the page, and in the shopper’s other tabs. - Strings come from Loveful’s translations. Labels such as “Save to wishlist” and “Saved by 3 shoppers” come from the app’s locale file with the merchant’s overrides from Loveful > Translations on top. The
data-*-textanddata-*-labelattributes below are only fallbacks for a missing translation. - Theme Liquid can read Loveful’s metafields. The signed-in customer’s saved variants (
refs_1) and each product’s and variant’s saved count (saved_count) are readable in your theme under the app’s namespace,app--<id>. Copy the namespace from yourloveful-wishlistsnippet (customer.metafields['app--…']); the examples below useapp--1234567.
loveful-button
The save button: a click saves the variant, a second click removes it. On a product page it follows the theme’s variant picker; as a product card heart (appearance="icon") it saves per product.
Write it yourself when the save button needs to sit somewhere the Wishlist button block can’t go: inside a buy buttons group, a sticky add to cart bar, a quick view, or a product card. Let Loveful render it on a standard product template (the Wishlist button block) and on product cards (the loveful-wishlist snippet’s heart).
Attributes
data-title, data-image, data-price, data-currency and data-available are only used for a guest’s list (kept on their device) and for the card drawn on the wishlist page straight after a save. A signed-in shopper’s wishlist page is rendered from the live variant, so a missing detail there corrects itself.
Markup inside it
None needed. The content is rebuilt on every state change from the merchant’s choice in Loveful’s storefront design window (Button content):
Whatever you write inside is shown only until the script runs, so write the label (or nothing). A card heart’s content is left alone: its heart is drawn in CSS.
State and events
It listens for the bus’s
item_added and item_removed, and on document for the variant picker events (shopify:product:select, variant:update, variant:change and change). It dispatches nothing itself: listen for the bus’s item_added and item_removed instead.
When the shopper isn’t signed in and the store requires an account to save, a click opens a sign-in dialog. When a signed-in shopper’s list is full (128 items), a click asks whether to remove the oldest item to make room.
Example
- Liquid
- HTML
snippets/my-save-button.liquid
Card heart mode
Withappearance="icon", the button is a heart for a product card:
- It’s saved when any variant of the product is saved, and a click on a saved heart removes every saved variant of the product.
- It ignores the variant picker.
- Its click doesn’t follow a link it sits in (the default and propagation are stopped), so it can go inside a card that is one big link.
- It needs only
data-vid,data-pidanddata-handle: when saving, it fetches the title, image, price and stock from/products/<handle>.js. - It’s positioned absolutely over the top right of its container, so the container needs
position: relative. The app embed’s Product card heart settings move it (top left, or in line) and colour it. - Loveful sets its
aria-labelto “Save to wishlist” or “Saved”.
loveful-wishlist snippet renders exactly this, with the saved state worked out in Liquid, so use it unless you need different markup.
Styling
Classes:loveful-button__icon, loveful-button__label. Style states with loveful-button[data-saved], loveful-button[data-pending] and loveful-button[appearance="icon"].
All of them: Save button and Product card heart.
loveful-count
The number of items on the shopper’s default list, kept current as they save and remove anywhere on the site. Write it yourself for a count beside your own header icon, in a mobile menu, or in a heading on the wishlist page. Let Loveful render it in the header with theloveful-wishlist snippet (type: 'count'), which wraps it in a link with a heart.
Attributes
Markup inside it
None. Its text is replaced with the count. Write the count from Liquid for the right number on first paint.State and events
It listens for the bus’s
item_added and item_removed. It dispatches nothing.
Example
- Liquid
- HTML
0 in Liquid and fills in when the script runs.
Styling
No classes of its own; it’sdisplay: inline-block with tabular numbers. Inside .loveful-header-link (the snippet’s link) it’s drawn as a badge, set with --loveful-header-count-bg, --loveful-header-count-fg and --loveful-header-count-size. See Header link and icon.
loveful-header-icon
A ready-made heart icon with a<loveful-count> badge, for a header that has no wishlist icon of its own.
Write it yourself: no block or snippet renders it. The snippet’s header link (type: 'count') is the alternative, drawn with CSS instead.
Attributes
Markup inside it
Leave it empty. When it’s empty, Loveful fills it with<svg class="loveful-header-icon__svg"> and a <loveful-count> (hidden at zero). If it already has any child element, Loveful leaves it as it is, so it’s empty until the script runs.
State and events
None of its own. The<loveful-count> inside it follows saves and removes.
Example
It isn’t a link, so wrap it in one:Styling
Classes:loveful-header-icon__svg, and loveful-header-icon loveful-count for the badge.
See Header link and icon and Saved count.
loveful-saved-count
“Saved by N shoppers” on a product page, for the whole product or the selected variant. It follows the variant picker and the shopper’s own saves, so it moves by one when they save or remove. Write it yourself to put the count somewhere the Saved count block can’t go, or on a product card. Let Loveful render it with the Saved count block on a product template.Attributes
Markup inside it
Without the
data-variant-counts script, the variant scope always counts from 0, and the product scope can’t tell which variants the shopper’s own saves belong to, so it stops following them. Without .loveful-saved-count__text, Loveful swaps the element’s own text and leaves its other children, such as an icon, in place.
Loveful draws the text as soon as the element is on the page, with the loveful.saved_count_one or loveful.saved_count_other translation, and again on every change. Render the text and hidden from Liquid too, so the count shows before the script runs.
State and events
It listens for the bus’s
item_added and item_removed, and for the variant picker events. It dispatches nothing.
Example
snippets/my-saved-count.liquid
data-scope="variant" and start from variant.metafields[loveful_ns].saved_count.value.
Styling
Classes:loveful-saved-count__text, loveful-saved-count__icon.
See Saved count.
loveful-list
The shopper’s own wishlist. It keeps the cards in step with saves and removes, draws a guest’s cards from their device, refreshes those with live prices and stock, and handles each card’s remove, Change and add to cart controls. Write it yourself to build a wishlist page with your own card markup or layout. Let Loveful render it with the Wishlist block: its cards follow the merchant’s storefront design and come with ratings, stock and the change options dialog set up.Attributes
Markup inside it
Inside a cloned card, Loveful fills whichever of these it finds:
Controls, on any card in the list:
State and events
It listens for the bus’s
item_added (adds a card, newest first) and item_removed (removes its card). On setup it publishes the loveful:wishlist_page_viewed Shopify customer event.
Example
The signed-in shopper’s cards come from the customer’srefs_1 metafield, the same list the Wishlist block renders. A guest gets an empty list that Loveful fills from their device.
sections/my-wishlist.liquid
<button class="loveful-card__change" type="button" data-loveful-change>Change</button> to the cards to offer the change options dialog.
Styling
Classes:loveful-list (the grid), loveful-card, loveful-card--top and loveful-card--side (image layouts), every loveful-card__* element above, loveful-card__remove--overlay and loveful-card__remove--link, loveful-list__empty, loveful-list__browse, loveful-list__sign-in.
See Wishlist page, Wishlist cards, Add to cart and Remove button.
loveful-share-link
The share controls for a signed-in shopper’s own wishlist: Copy link, Reset link and, when email sharing is on, Email wishlist. Copy and reset put the link on the clipboard; email opens a form in a dialog. Write it yourself to put the share controls somewhere other than above the list, or with your own buttons. Let Loveful render it with the Wishlist block, which adds it only once a share page is set up in Loveful’s Share settings and matches email sharing to those settings.Attributes
Loveful’s buttons and messages use your translations (
loveful.share_copy, loveful.share_reset, loveful.share_copied and the rest), set on Settings › Translations.
Markup inside it
Leave it empty for Loveful’s own buttons:button.loveful-share-link__copy, button.loveful-share-link__reset and button.loveful-share-link__email.
Or write your own controls. When the element already has children, Loveful leaves them in place and handles clicks on any of these inside it:
The “Copied!” and “Link reset” messages replace only the button’s words, then the original words come back. Loveful swaps the content of a
[data-loveful-label] element inside the button if there is one, or else the button’s last piece of text, so an icon inside the button stays.State and events
It dispatches these on itself, bubbling, so they can be caught on
document:
Example
- Your own controls
Styling
Classes:loveful-share-link__copy, loveful-share-link__reset, loveful-share-link__email. The email form uses the dialog classes (loveful-dialog, loveful-email-dialog, loveful-dialog__field, loveful-dialog__actions).
See Share buttons, Dialogs and Form fields.
loveful-shared-list
A wishlist someone shared, loaded from the token in the share link (?loveful_token=…). It works for anyone: the viewer doesn’t need to be signed in.
Write it yourself to show a shared list on a page of your own design, or as a plain list without cards. Let Loveful render it with the Shared wishlist block, on the page picked in Loveful’s Share settings: share links open that page.
It has two modes, picked by its markup:
- Block mode: it contains a
ul.loveful-list. The items are drawn as cards from yourtemplate[data-loveful-card], exactly like<loveful-list>, and refreshed with live prices and stock. - Bare mode: it doesn’t. Loveful replaces its content with a plain list of links.
Attributes
Markup inside it
Block mode:
Leave the remove and Change controls out of the template: it’s someone else’s list. A card’s
form.loveful-card__cart adds to the viewer’s cart, as on the wishlist page.
Bare mode: leave it empty, or put a loading message inside. Loveful replaces it with:
<p class="loveful-shared-list__empty"> with the loveful.shared_empty translation for an empty list, or <p class="loveful-shared-list__missing"> with the loveful.shared_not_available translation for a missing or reset link. Bare mode shows the price saved with the item, not the live price, formatted for the page’s language.
State and events
Nothing is reflected on the element. It loads once, afterloveful.ready. When the list has items, it:
- sets the hidden cart attribute
_loveful_shareto the token (or<token>:<send id>when the link came from a share email’ssparameter), so an order can be traced back to the share; - publishes the
loveful:share_viewedShopify customer event.
Example
- Block mode
- Bare mode
- Fixed token
templates/page.shared-wishlist.liquid
Share links Loveful makes always point at the share page picked in Loveful’s Share settings, with
?loveful_token=. Put the element on that page, or set data-param only for links you build yourself.Styling
Block mode uses the<loveful-list> classes and variables. Bare mode’s classes are loveful-shared-list (an auto-filling grid, 12rem minimum columns), loveful-shared-list__item, __link, __img, __body, __title, __price, __empty and __missing; it has no variables of its own, so style the classes directly. See Shared.