If you've ever wanted to allow customers to browse by product vendor or type, we just added a feature that allows you to do this easily. Shopify uses Liquid for shop templates, and you can now get lists of product vendors and types in Liquid.
For example, to make a list of links to each vendor in a shop, you can use this code:
{% for product_vendor in shop.vendors %}
<li>{{ product_vendor | link_to_vendor }}</li>
{% endfor %}
Or, to make a list of links to each product type in a collection, you can now do this:
{% for product_type in collection.all_types %}
<li>{{ product_type | link_to_type }}</li>
{% endfor %}
Previously to get the same information, you had to use an ugly workaround like this:
{% assign vendor_list = '' %}
{% for product in collections.all.all_products %}
{% if vendor_list contains product.vendor %}
{% else %}
<li>{{ product.vendor }}</li>
{% capture temp %}{{ vendor_list }}{{ product.vendor }}{% endcapture %}
{% assign vendor_list = temp %}
{% endif %}
{% endfor %}
The four variables that were added are
shop.vendors
shop.types
collection.all_vendors
collection.all_types
Take a look at the Shop and Collection Liquid documentation in the wiki for more details.
Topics:
Join 379,633 entrepreneurs who already have a head start.
Get free online marketing tips and resources delivered directly to your inbox.
Thanks for subscribing
You’ll start receiving free tips and resources soon. In the meantime, start building your store with a free 14-day trial of Shopify.