Use <ooo-wl-wishlist-button> to add or remove a product from a customer’s wishlist. Wishlist Power handles the request and updates the button state. The component uses your theme’s HTML and CSS; it does not provide an encapsulated button design.

Before using it, install Wishlist Power and enable its “Wishlist Setup” app embed in Online Store → Themes → Customize → App embeds.

Basic example

<ooo-wl-wishlist-button product-id="{{ product.id }}" handle="{{ product.handle }}" loading>
  <button type="button">
    <span class="ooo-wl-wishlist-button-add">Add to wishlist</span>
    <span class="ooo-wl-wishlist-button-remove">Remove from wishlist</span>
  </button>
</ooo-wl-wishlist-button>

The component needs an inner <button>. Keep type="button" so clicking it does not submit a surrounding product form.

Input attributes

Attribute Required Behavior
product-id Yes Shopify product ID.
handle Yes Product handle used to look up the product and wishlist state.
variant-id No Explicit variant ID. If present, the component does not watch the product form for variant changes; update the attribute yourself.
loading Recommended Add this in the initial markup. The component removes it after checking the wishlist state.

Without variant-id, the component looks for a variant in the URL’s variant parameter or in the associated product form. On a product page, it also listens for supported variant changes. For a cart line or product card with a known variant, pass that variant explicitly.

Wishlist Power can be configured to save whole products or individual variants. In product mode, a product with multiple variants is saved without a variant ID; in variant mode, the selected variant is saved. Check both modes if your integration is reused across stores.

State and styling

The component sets aria-checked="true" or "false" on the inner button. During a click request it sets aria-busy="true", disables the button, then sets aria-busy="false" when the request finishes. It also updates the button’s aria-label from Wishlist Power’s translations.

ooo-wl-wishlist-button[loading] {
  visibility: hidden;
}

ooo-wl-wishlist-button button[aria-checked="true"] .ooo-wl-wishlist-button-add,
ooo-wl-wishlist-button button[aria-checked="false"] .ooo-wl-wishlist-button-remove {
  display: none;
}

Do not treat a click or the temporary aria-checked change as proof that an item was saved: the component updates the state optimistically while the request is pending. For code that must run only after a successful add or remove, listen for ooo-wishlist:product-added or ooo-wishlist:product-removed on document. See the JavaScript API for event details.

When Wishlist Power requires a logged-in customer and the current visitor cannot access a wishlist, the component does not attach its wishlist click handler. Test guest and signed-in behavior for your store’s access setting.

Variant warning

In variant mode, the component can set show-variant-warning="true" when another variant of the product is already saved. It also sets --ooo-wl-variants-added-count on the component. You may add an optional message and style it using those values:

<ooo-wl-wishlist-button product-id="{{ product.id }}" handle="{{ product.handle }}" loading>
  <button type="button">Add to wishlist</button>
  <p class="wishlist-variant-warning">You already have another variant in your wishlist.</p>
</ooo-wl-wishlist-button>
ooo-wl-wishlist-button .wishlist-variant-warning { display: none; }
ooo-wl-wishlist-button[show-variant-warning="true"] .wishlist-variant-warning { display: block; }

For a step-by-step theme tutorial, see Add a custom wishlist button. To display the current item count, see <ooo-wl-wishlist-count>.