Skip to main content

Custom Buttons

You can add wishlist buttons anywhere on your site using custom HTML. This is useful for creating tailored experiences that match your brand.

Updated this week

Custom Wishlist Buttons

You can add wishlist buttons anywhere on your site using custom HTML. This is useful for creating tailored experiences that match your brand.

Basic Button

Add this HTML anywhere in your theme to create a wishlist button:

html <button class="wishlist-btn" data-product-handle="your-product-handle"> Add to Wishlist </button>

Replace your-product-handle with the actual product handle (the URL-friendly name of the product).

Button with Icon

Add an icon to your button using the data-icon-type attribute:

html <button class="wishlist-btn" data-product-handle="your-product-handle" data-icon-type="icon_heart"> Add to Wishlist </button>

Available Icon Types

Value

Description

icon_heart

Heart icon

icon_star

Star icon

icon_bookmark

Bookmark icon

icon_gift

Gift icon

icon_plus

Plus icon

custom

Keep your own markup (no icon injected)

none

No icon

Icon Position

Control where the icon appears relative to the text:

html <button class="wishlist-btn" data-product-handle="your-product-handle" data-icon-type="icon_heart" data-icon-position="after"> Add to Wishlist </button>

Value

Description

before

Icon appears before text (default)

after

Icon appears after text

Icon-Only Button

Create a button with just an icon (no text):

html <button class="wishlist-btn" data-product-handle="your-product-handle" data-icon-type="icon_heart" data-text-hidden="true"> </button>

Success Text

Change the button text after a successful add:

html <button class="wishlist-btn" data-product-handle="your-product-handle" data-success-text="Saved!"> Add to Wishlist </button>

After the customer adds the item, the button text changes to “Saved!” and shows a success state.

Specific Variant

Target a specific variant instead of the default:

html <button class="wishlist-btn" data-product-handle="your-product-handle" data-variant-id="12345678901234"> Add to Wishlist </button>

Cart Integration (Save for Later)

Create a button that adds to wishlist AND removes from cart:

html <button class="wishlist-btn wishlist-save-for-later" data-product-handle="your-product-handle" data-variant-id="12345678901234" data-line-item-key="abc123:def456" data-success-text="Saved!"> Save for Later </button>

The data-line-item-key should be the cart line item key. When clicked:

  1. The item is added to the wishlist

  2. The item is removed from the cart

  3. The button text changes to the success text

Complete Attribute Reference

Attribute

Required

Description

data-product-handle

Yes

Product URL handle

data-variant-id

No

Specific variant ID

data-icon-type

No

Icon to display

data-icon-position

No

before or after

data-text-hidden

No

true to hide text

data-success-text

No

Text after successful add

data-line-item-key

No

Cart line item key for removal

Liquid Examples

Product Page Button

liquid <button class="wishlist-btn" data-product-handle="#{{ product.handle }}" data-variant-id="#{{ product.selected_or_first_available_variant.id }}" data-icon-type="icon_heart" data-success-text="#{{ 'wishlist.saved' | t }}"> #{{ 'wishlist.add_to_wishlist' | t }} </button>

Cart Page Save for Later

liquid {% for item in cart.items %} <button class="wishlist-btn wishlist-save-for-later" data-product-handle="#{{ item.product.handle }}" data-variant-id="#{{ item.variant_id }}" data-line-item-key="#{{ item.key }}" data-success-text="Saved!"> Save for Later </button> {% endfor %}

CSS Classes

The button automatically receives these classes based on state:

Class

When Applied

success

Item is in the wishlist

busy

API request is processing

Example CSS

```css .wishlist-btn { background: transparent; border: 1px solid #333; padding: 10px 20px; cursor: pointer; transition: all 0.2s; }

.wishlist-btn.success { background: #e8f5e9; border-color: #4caf50; color: #4caf50; }

.wishlist-btn.busy { opacity: 0.6; pointer-events: none; } ```

Toggle Behavior

Custom buttons toggle between add and remove states:

  • Click once to add to wishlist

  • Click again to remove from wishlist

The success class is added or removed accordingly, and the icon switches between outline and filled states.


Did this answer your question?