Many store owners want to display the contents of Wishlist on selected pages of the store. In particular, we have received requests to display the wishlist contents at the following locations:
- Account Page
- Custom Popup
With the Smart Wishlist Public API, it has become possible to display the wishlist contents anywhere on the entire store. In this article, we shall explain how to do this. It assumes that the path to wishlist page is default /a/wishlist. If it has been changed, you need to replace it with the updated path.
1: Create an empty HTML <div>. Assign it a unique id.
2. Check if the user is logged in. If the user is logged in we shall display Express Wishlist, otherwise the User Account Wishlist shall be displayed.
3. Depending on the #2, make a AJAX request to the /a/wishlist endpoint using Smart Wishlist Public API.
For the starters, we have created a readymade code which can be embedded in any layouts/snippets/templates/sections of the theme to display the contents of wishlist. It may not work if you place it in any assets of the theme.