Hiding a collection programatically from the Catalog page

tscanlan
Visitor
3 0 0

I want to use an if statement to check if a collection is "Creations" and prevent it from being displayed in the Catalog/store. I want to use this collection as a set of images to display on a custom page (I'll remove the add to cart and price in the template as well). Thank you for any help! I am using the Debut theme. I feel like I am close with if collections.title = "Creations" but I cannot get it to work.

Replies 3 (3)

LuckyNigam
Pathfinder
142 8 14

Hi @tscanlan 

Instead of this you can use 

{% if collection.title conatins 'collection name ' %}

  your code here

{% endif %}

If you have again issue with this so you can contact me on skype ( skype id : cid.6072cc42f2bf365c).

 

Thanks.

Not applicable

Hi @tscanlan 

Aibek is here from Speedimize.io 

You write this wrong, it should be like this:

{% if collection.title == "Creations" %}
code here
{% endif %}

You specified collections in the plural. Plus, when comparing, you must specify ==

tscanlan
Visitor
3 0 0

I set a product type as "nodisplay" and I used {% if product.type != 'nodisplay' %} to skip over displaying those products in the "Catalog." The products labeled with "nodisplay" do not show up as expected but I am having a problem. The store displays only 7 photos (it would be 8 minus the 1 hidden product) and says "Sorry, there are no products in this collection."  (see image)

I want to remove a collection from the global object with something like: {% collection remove: '/collections/creations' %} but I don't know what that syntax would be

How can I keep this product type from showing up and also stop from breaking the store?

tscanlan_0-1618876713141.png

 

My pieces of code I have bolded to make them easier to find:

<ul class="grid grid--uniform{% if collection.products_count > 0 %} grid--view-items{% endif %}">
 
{% endif %}
        {% for product in collection.products %}
 {% if product.type != 'nodisplay' %} 
 
          <li class="grid__item grid__item--{{section.id}} {{ grid_item_width }}">
            {% include 'product-card-grid', max_height: max_height, product: product, show_vendor: section.settings.show_vendor %}
          </li>
        {% else %}
          {% comment %}
          Add default products to help with onboarding for collections/all only.
 
          The onboarding styles and products are only loaded if the
          store has no products.
          {% endcomment %}
          {% if collection.handle == 'all' and collection.all_vendors.size == 0 and collection.all_types.size == 0 %}
            <li class="grid__item">
              <div class="grid grid--uniform">
                {% for i in (1..limit) %}
                  <div class="grid__item {{ grid_item_width }}">
                    <div class="grid-view-item">
                      <a href="#" class="grid-view-item__link">
                        <div class="grid-view-item__image">
                          {% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %}
                          {{ 'product-' | append: current | placeholder_svg_tag: 'placeholder-svg' }}
                        </div>
                        <div class="h4 grid-view-item__title">{{ 'homepage.onboarding.product_title' | t }}</div>
                        <div class="grid-view-item__meta">
                          <span class="product-price__price">$19.99</span>
                        </div>
                      </a>
                    </div>
                  </div>
                {% endfor %}
              </div>
            </li>
          {% else %}
            {%- assign is_empty_collection = true -%}
          {% endif %}
        {% endif %}
        {% endfor %}
               
      </ul>