<p>You can definitely use Shortlist for this.  Here's some code to get you started.  Note in this I allow the favouriting of both products and pages/articles.</p>

<p>Code to let user add the favourites -</p>

<pre><code>    {% set item = craft.shortlist.item(id) %}
    &lt;span class="favStar"&gt;&lt;a class="shortlist_action reset-a" title="Add To Favourites" href="{{ item.addActionUrl }}"&gt;&lt;i class="favStar__icon icon-"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/span&gt;
</code></pre>

<p>And to display the favourites/wishlist - first we prepare by separating products from regular elements:</p>

<pre><code>        {# Prepare the output data #}
        {% set lists = craft.shortlist.lists %}
        {% set favouriteArticleIDs = [] %}
        {% set favouriteProductIDs = [] %}

        {% if lists|length %}
            {# We just store everything in one list... #}
            {% for list in lists %}
                {% for item in list.items %}
                    {% set favId = item.elementId %}
                    {% if item.element.elementType == 'Commerce_Product' %}
                        {% set favouriteProductIDs = favouriteProductIDs|merge([favId]) %}                          
                    {% else %}
                        {% set favouriteArticleIDs = favouriteArticleIDs|merge([favId]) %}
                    {% endif %}                
                 {% endfor %}
            {% endfor %}
        {% endif %}
</code></pre>

<p>...then to actually fetch &amp; display the results we do this:</p>

<pre><code>            {% if not favouriteProductIDs|length %}

                &lt;strong&gt;No favourite products?  Why not add some?&lt;/strong&gt;

            {% else %}

                {% set products = craft.commerce.products.id(favouriteProductIDs).order('title').with('variants') %}                    

                {% import "_macros/productPreviewsLib" as productPreviewsLib %}

                {{
                    productPreviewsLib.productPreviews(products,
                    {
                        'display' : 'Table',
                        'showUnavailables' : true,
                    })
                }}

            {% endif %}
</code></pre>

<p>(The macro just does <code>{% for product in products %}</code> etc)</p>

<p>That should get you started!</p>

CC BY-SA 3.0
2017-02-02T23:47:02.357Z
Jeremy, is Shortlist working on an up to date Craft install? Docs show 1.0.2 as the last version in 2015 which was prior to Craft 2.5. I'm wondering if it's been updated but just not documented on the changelog as I see references to a version 1.1??
shorn
CC BY-SA 3.0
2017-02-03T00:52:42.363Z
I'm using Shortlist 1.0.4 which I believe it the latest release, with the latest Craft and Commerce releases, no issues.
Jeremy Daalder
CC BY-SA 3.0
2017-02-03T08:38:13.857Z
Cool, thanks! It's currently the only plugin out there that seems like it fits my need, but from the site it looks a little neglected!
shorn
CC BY-SA 3.0
2017-01-17T23:07:30.127Z
2017-01-17T23:07:30.127Z
Jeremy Daalder
<p>Digging up an old question here but in order to display the title (and other field data) for Commerce products you need to use <code>{{ item.element.title }}</code></p>

<p>Thanks to James Greig for that tip.</p>

CC BY-SA 4.0
2018-05-18T14:37:15.630Z
2018-05-21T07:44:37.617Z
2018-05-21T07:44:37.617Z
foamcow
<p>I'd like to use the <a href="https://squarebit.co.uk/software/craft/shortlist/overview" rel="nofollow noreferrer">Shortlist</a> plugin to allow visitors to create product wishlists - using Craft Commerce.</p>

<p>Currently, I have setup the 'add to wishlist' function, but I am not sure how to then display the items that a user has add to their wishlist.</p>

<p>The code below, is the example given on the plugin docs for how to loop through the items a user has added, but this does not produce the required results for commerce products.  </p>

<pre><code>{% if shortlistLists is empty %}
You have no lists at the moment.
{% else %}
    {% for list in lists %}
    &lt;h3&gt;{{ list.title }}&lt;/h3&gt;

    {% if list.items is empty %}
    No items in this list
    {% else %}
    &lt;ul&gt;
        {% for item in list.items %}
            &lt;li&gt;{{ item.title }} (&lt;a href="{{ item.removeActionUrl }}"&gt;Remove&lt;/a&gt;)&lt;/li&gt;
        {% endfor %}
    &lt;/ul&gt;
    {% endif %}
    {% endfor %}
{% endif %}
</code></pre>

<p>The docs for the plugin are available here - <a href="https://squarebit.co.uk/software/craft/shortlist/usage/quickstart" rel="nofollow noreferrer">https://squarebit.co.uk/software/craft/shortlist/usage/quickstart</a></p>

<p>If anyone could point me in the right direction as to how to successfully use the plugin in conjunction with Craft Commerce, that would be much appreciated.</p>

<plugin-craftcommerce><plugin-shortlist>
Using Shortlist plugin to create product wishlist
# Using Shortlist plugin to create product wishlist

(Asked by: username_0 on 2017-01-16)

I'd like to use the Shortlist plugin to allow visitors to create product wishlists - using Craft Commerce.
Currently, I have setup the 'add to wishlist' function, but I am not sure how to then display the items that a user has add to their wishlist.
The code below, is the example given on the plugin docs for how to loop through the items a user has added, but this does not produce the required results for commerce products.  
{% if shortlistLists is empty %}
You have no lists at the moment.
{% else %}
    {% for list in lists %}
    {{ list.title }}

    {% if list.items is empty %}
    No items in this list
    {% else %}
    
        {% for item in list.items %}
            {{ item.title }} (Remove)
        {% endfor %}
    
    {% endif %}
    {% endfor %}
{% endif %}

The docs for the plugin are available here - https://squarebit.co.uk/software/craft/shortlist/usage/quickstart
If anyone could point me in the right direction as to how to successfully use the plugin in conjunction with Craft Commerce, that would be much appreciated.

**Tags:** plugin-craftcommerce, plugin-shortlist

---

## 2 answers

### Answer by username_1 on 2017-01-17. Score: 2

You can definitely use Shortlist for this.  Here's some code to get you started.  Note in this I allow the favouriting of both products and pages/articles.
Code to let user add the favourites -
    {% set item = craft.shortlist.item(id) %}
    

And to display the favourites/wishlist - first we prepare by separating products from regular elements:
        {# Prepare the output data #}
        {% set lists = craft.shortlist.lists %}
        {% set favouriteArticleIDs = [] %}
        {% set favouriteProductIDs = [] %}

        {% if lists|length %}
            {# We just store everything in one list... #}
            {% for list in lists %}
                {% for item in list.items %}
                    {% set favId = item.elementId %}
                    {% if item.element.elementType == 'Commerce_Product' %}
                        {% set favouriteProductIDs = favouriteProductIDs|merge([favId]) %}                          
                    {% else %}
                        {% set favouriteArticleIDs = favouriteArticleIDs|merge([favId]) %}
                    {% endif %}                
                 {% endfor %}
            {% endfor %}
        {% endif %}

...then to actually fetch & display the results we do this:
            {% if not favouriteProductIDs|length %}

                No favourite products?  Why not add some?

            {% else %}

                {% set products = craft.commerce.products.id(favouriteProductIDs).order('title').with('variants') %}                    

                {% import "_macros/productPreviewsLib" as productPreviewsLib %}

                {{
                    productPreviewsLib.productPreviews(products,
                    {
                        'display' : 'Table',
                        'showUnavailables' : true,
                    })
                }}

            {% endif %}

(The macro just does {% for product in products %} etc)
That should get you started!

> **Comments:**
> **username_2**: Jeremy, is Shortlist working on an up to date Craft install? Docs show 1.0.2 as the last version in 2015 which was prior to Craft 2.5. I'm wondering if it's been updated but just not documented on the changelog as I see references to a version 1.1??  
> **username_1**: I'm using Shortlist 1.0.4 which I believe it the latest release, with the latest Craft and Commerce releases, no issues.  
> **username_2**: Cool, thanks! It's currently the only plugin out there that seems like it fits my need, but from the site it looks a little neglected!  

---

### Answer by username_3 on 2018-05-18. Score: 1

Digging up an old question here but in order to display the title (and other field data) for Commerce products you need to use `{{ item.element.title }}`

Thanks to James Greig for that tip.


---

