Search code examples
bigcartel

Display only one product category on Big Cartel Home page


I would like to only display one category of products on the Big Cartel home page. This is the code from the standard NEAT theme.

Can I adjust the "get" tag to accomplish this? Or is another if/for required?

{% get products from products.all limit: theme.featured_products %}
  {% if products != blank %}
    <ul class="products_list">
        {% for product in products %}
                             <li class="{{ product.css_class }}">
                <a href="{{ product.url }}">
                    <img alt="Image of {{ product.name | escape }}" src="{{ product.image | product_image_url | constrain: '900' }}">
                    <b>{{ product.name }}</b>
                    <i>{{ product.default_price | money_with_sign }}</i>
                    {% case product.status %}
                        {% when 'active' %}
                            {% if product.on_sale %}<em>On Sale</em>{% endif %}
                        {% when 'sold-out' %}
                            <em>Sold Out</em>
                        {% when 'coming-soon' %}
                            <em>Coming Soon</em>
                    {% endcase %}
                </a>
            </li>
                    {% endif %}
        {% endfor %}
    </ul>
  {% else %}
    <p class="no_results">No products found.</p>
  {% endif %}
{% endget %}

Solution

  • You'll need to use a basic "for" loop to retrieve products from specific categories, using "get" doesn't work for that at the moment:

    {% for product in categories.accessories.products limit:6 %}
      <p>{{ product.name }}: {{ product.price }}</p>
    {% endfor %}
    

    Replace "accessories" with whatever permalink represents the category you're trying to pull from and you're all set.