Product Tags - CrystalCommerce Liquid Documentation for Designers

Product Tags

The tagged_with block is available to all liquid templates. It provides a collection of products that are tagged by the admin with a product tag. The passed in tag is arbitrary and set by the client Admin.

Special Tags

There is currently only one type of special tag available. Tags starting with a ! are related product tags. This means that if Adarkar Wastes is tagged “!neat” and Air Elemental is tagged “!neat”, Air Elemental will show up in Adarkar Waste’s list of related products. However, it will not if they are both tagged as “neat” without the exclamation point.

Options

reversed
The reversed option takes no arguments, but if present the order will be reversed.
limit
The limit option takes an integer and will limit your results to that amount. Default is 10.
page
The page option either takes an integer or a string. If a string is passed, it is expected to be a variable on the page. This lets you do a loop through them in a slider (see below). Default is 1.
order
The order of the products pulled from the database. Supported values: name, random, sell_price, buy_price, top_sellers. Default is name. BE CAREFUL with random. It is pretty hard on the database and may slow down load times a great deal. If your pages are loading slowly, random may be the culprit.
in_stock
If the in_stock keyword is used, then only products which are in stock will be shown.
buylist
The buylist option takes no arguments, but if present the products will be marked as if you were browsing the site in buylist mode.

Syntax

Simplest case:

{% tagged_with 'Hot Seller' do products %}
  <table border="0" class="invisible-table" width="100%">
    {% include 'product' with products %}
  </table>
{% endtagged_with %}

Multiple tags can be specified, delimited by a comma.

{% tagged_with 'Hot Seller,Awesome Stuff' do products %}
  <table border="0" class="invisible-table" width="100%">
    {% include 'product' with products %}
  </table>
{% endtagged_with %}

A limit can also be specified (the default is 10):

{% tagged_with 'Awesome Stuff' do products limit:5 %}
  <table border="0" class="invisible-table" width="100%">
    {% include 'product' with products %}
  </table>
{% endtagged_with %}

The products collection can be used just like on category_browse and search:

{% tagged_with 'Judge Promos' do products limit:5 %}
  {% if products.size > 0 %}
    <table border="0" class="invisible-table" width="100%">
      {% include 'product' with products %}
    </table>
  {% else %}
    There are no judge promos! :(
  {% endif %}
{% endtagged_with %}

Slider usage with limit, order, page and reversed:

<div id="slider" class="clearfix">
  <ul>
    {% for i in (1..5) %}
    <li>
    {% tagged_with 'Frontpage Slider' do products reversed limit:4 order:sell_price page:i %}
      <table cellpadding="0" cellspacing="0">
        <tr>
        {% for product in products %}
          <td{% if forloop.first %} class="first"{% endif %}>
            <div>
              <a class="sliderImgLink" href="{{ product.url }}"><img src="{{ product.main_photo | photo_url: "medium" }}" width="100" height="100" /></a>
              <a class="sliderProductName" href="{{ product.url }}">{{ product.name }}</a>
              <span class="sliderProductPrice">{{ product.price_range }}</span>
            </div>
          </td>
        {% endfor %}
        </tr>
      </table>
    {% endtagged_with %}
    </li>
  {% endfor %}
  </ul>
</div>

Use of a variable name for the tag (where tagname is whatever variable you want to use):

{% assign tagname = 'Hot Sellers' %}
{% tagged_with tagname do products %}
  <table border="0" class="invisible-table" width="100%">
    {% include 'product' with products %}
  </table>
{% endtagged_with %}