I am currently using an app for my wishslist (wishlist king) and I would like to create a button on the header next to the Account, search and cart button to redirect on the wishlist page.
(as you can see the app provide a floating button on the bottom right but I don’t really like it).
I can’t find a way to do so since this part of the header isn’t accessible on the Theme customizer. (I think our developer add the different icons there when we create the website).
To add a wishlist icon to your Shopify header next to the account, search, and cart icons, you’ll need to modify your header.liquid file. Based on the provided code,
Follow these steps:
Locate the wishlist URL : First, ensure you have the correct URL for your wishlist page. This URL should be available from the wishlist app you are using (e.g., Wishlist King).
Add the Wishlist Icon : Insert the following code snippet into the header.liquid file, placing it after the existing account, search, and cart links:
{%- if section.settings.show_wishlist -%}
{{ 'header.general.open_wishlist' | t }}
{%- if section.settings.show_icons -%}
{%- render 'icon' with 'wishlist', class: 'header__nav-icon' -%}
{%- else -%}
{%- render 'icon' with 'wishlist', class: 'header__nav-icon' -%}
{{ 'header.general.wishlist' | t }}
{%- endif -%}
{%- endif -%}
Make sure to replace {{ routes.wishlist_url }}with the actual URL of your wishlist page if it’s not defined in your routes. If your app provides a specific method or variable for the wishlist URL, use that instead.
Icon Rendering: Ensure that the "icon"snippet includes a definition for the wishlist icon. If it does not exist, you will need to create one or use a suitable icon that fits your design.
Translation: The {{ ‘header.general.open_wishlist’ }} part should correspond to a translation entry in your locale files. You may need to add the necessary text if it doesn’t exist.
Test the Changes: After making these modifications, save the header.liquid file and preview your store to ensure the wishlist icon appears correctly in the header and links to the wishlist page.
If you run into any issues or need further customization, feel free to ask!
I don’t have any wishlist icon in my icon.liquid Snippet, can you help me adding one ? I don’t know how to create the icon.
Also I don’t really understand the thing about the routes : if i copy paste the link to the page instead of {{ routes.wishlist_url }} it won’t work ? (the link is www.ekyog.com/apps/wishlist) So i put this link in the code you provide…
Sure, @Vic1208 ! Let’s walk through adding a wishlist icon to your Shopify store and addressing the routes question. I’ll make it easy to follow:
Add a Custom Wishlist Icon in icon.liquid
Follow these steps:
Online Store > Themes > Edit Code
In the Snippets folder, open icon,liquid
Add the following code to render a heart-shaped wishlist icon:
{% case icon %}
{% when 'wishlist' %}
{% endcase %}
This SVG renders a hearticon, commonly used for wishlists.
Update the Header Code with Your Wishlist Link
you can use a direct link instead of {{ routes.wishlist_url}}. Since your link is “https://www.ekyog.com/apps/wishlist”, we’ll insert it directly into the header code.
Update the code I shared earlier in the header.liquid like this:
[
Open Wishlist
{%- render 'icon' with 'wishlist', class: 'header__nav-icon' -%}
](https://www.ekyog.com/apps/wishlist)
Style the Icon:
You can style the icon using CSS to ensure it fits well with the other icons:
.header__nav-icon.icon-wishlist {
width: 24px;
height: 24px;
margin-left: 10px; /* Adjust spacing between icons */
stroke-width: 2;
color: #333; /* Adjust color to match your theme */
transition: color 0.2s;
}
.header__nav-icon.icon-wishlist:hover {
color: #e63946; /* Change to red on hover */
}
After making these changes:
Save both the header.liquid and icon.liquid files.
If I was able to help you, please don’t forget to Like and mark it as the Solution!