A set of files used to implement a simple customer wishlist on a Shopify store.
Version: 2.3.0 - Compatible with Online Store 2.0
Previous Versions:
To begin using Shopify Wishlist, you must copy some of the files in this repo into your Shopify theme code.
Note: This setup assumes that you have a snippet for displaying a product card.
Files to copy:
Repo File | Shopify Theme Location |
---|---|
button-wishlist.liquid |
snippets/ |
icon-heart.liquid |
snippets/ |
wishlist-template.liquid |
sections/ |
product-card-template.liquid |
sections/ |
page.wishlist.json |
templates/ |
product.card.json |
templates/ |
Wishlist.js |
assets/ |
- Place the
button-wishlist.liquid
snippet inside your existing product card snippet, or on theproduct.liquid
template{%- render 'button-wishlist', product: product -%}
- This will allow customer's to add/remove items to/from their wishlist
- Replace the snippet in the
product-card-template.liquid
section with your existing product card snippet- Same snippet from step 1
- Your product card snippet may use a different product variable name, double check it 👍
- Add your product card element classname to the
selectors
object inWishlist.js
- Example: If your product card classname is
.product-item
, theselectors
variable would look like this:const selectors = { button: '[button-wishlist]', grid: '[grid-wishlist]', productCard: '.product-item', // your classname here };
- Example: If your product card classname is
- Create a new page in the Shopify admin:
- Admin > Online Store > Pages > Add Page
- Set the new page's
template
topage.wishlist
- This page will display a customer's saved wishlist items
- Place the script in
theme.liquid
before the closing</head>
tag<script src="{{ 'Wishlist.js' | asset_url }}" defer="defer"></script>
That's it! When viewing your Shopify store, you should see the wishlist buttons inside your product cards (likely on collections pages) or on the product template. A click on the wishlist button will add/remove the item from the customer's wishlist and trigger active styling on the button. After adding wishlist items, you can view your wishlist by navigating to the page created in step 3.
- This wishlist uses Javascript and localStorage to save the customer's wishlist on their browser. The localStorage will not persist if the user clears browser storage or browses in incognito mode.
- As customers browser products and adds them to their wishlist, the script will automatically set any wishlist buttons to active state if the corresponding product is already included in the wishlist.
- These files come with no styling or structure so that you can customize as needed. This is intended to bring you the base functionality of a wishlist with no frills.
- If you are working in an unpublished theme, you will need to create the new templates on the published theme as well. The Shopify admin will only allow you to assign a page to a template if the template exists on the published theme.
- If you are upgrading to the Online Store 2.0 version, you will be required to delete the older
.liquid
wishlist and product card templates.