Remove the price from collection page

Shopify Partner
4 0 0

Hi folks, 

I am using the Radiance theme and I am trying to remove the price from a few products. I need the price removed from the product page and the collection page. Some suppliers do not allow me to display prices. We have successfully removed the price from the products page by creating a new template for the products page but the price still shows up on the collections page. It would be great to have the collections template look to see if the "product.Hidden-price.liquid" template has been used for this product and use the correct template for the collections page. At first, I was thinking of using the Tags or Price field for this but the Template field is in the Products page and there should be a way to do this right?

The following is a copy of my new template called "product.Hidden-price.liquid" and I choose that on the product page in the admin when I want the price hidden from the product page. The second chunk of code is the original and unchanged "product-grid-item.liquid" template that should be changed. I believe a simple if statement should do the trick but I need a bit of help with this. Anyone feel up to it? Thanks!

product.Hidden-price.liquid

<div id="col-main">

  <div id="product" class="clearfix content">

    <div id="product-information">

      <p id="add-to-cart-msg"></p>

      <div id="product-header" class="diagonal-divider clearfix">

        <div id="product-header-title">
          <h1 id="product-title">{{ product.title }}</h1>
          {% if settings.show_vendor %}<h2 id="product-vendor">{{ product.vendor | link_to_vendor }}</h2>{% endif %}
        </div>

        {% if product.available %}
        
          {% assign hide_default_title = false %}
          {% if product.variants.size == 1 and product.variants.first.title contains 'Default' %}
            {% assign hide_default_title = true %}
          {% endif %} 
          
          <form action="/cart/add" method="post" class="variants" id="product-actions" enctype="multipart/form-data">
            <div class="options clearfix">  

              <div class="variants-wrapper clearfix {% if hide_default_title %}visuallyhidden{% endif %}"> 
                <select id="product-select" name="id">
                  {% for variant in product.variants %}
                  <option value="{{ variant.id }}" {% if variant == product.selected_or_first_available_variant %}selected="selected"{% endif %}>{{ variant.title | escape }} - {{ variant.price | money }}</option>
                  {% endfor %}
                </select>
              </div>            
              {% assign variant = product.selected_or_first_available_variant %}  
              <div id="purchase">
                <p> <strong><a href="/pages/contact-us">Contact us for Price</a></strong> </p>
               
              </div>

            </div><!-- /.options -->
          </form>

        {% else %}
          <div id="product-actions" class="sold-out">
            <div id="purchase">
              <p class="price">Sold out.</p>      
            </div>
          </div>      
        {% endif %}
      </div><!-- /#product-header -->

      
      <div class="description">
        {{ product.description }}
        {% include 'social-sharing' %} 
      </div>            

    </div><!-- /#product-information -->
    
    <div id="product-gallery"{% if settings.main_image_display == 'Zoom-in' and product.images.size > 0 %} class="zoom-in"{% endif %}>
	  {% assign featured_image = product.selected_or_first_available_variant.featured_image | default: product.featured_image %}
      <div id="active-wrapper">
        {% if settings.main_image_display == 'Lightbox' %}
        <a href="{{ featured_image | img_url: '1024x1024' }}" title="{{ featured_image.alt | escape }}" rel="fancybox">
        {% endif %}     
          <img style="max-width:303px" src="{{ featured_image | img_url: 'large' }}" alt="{{ product.title | escape }}" id="large-thumb" />
        {% if settings.main_image_display == 'Lightbox' %}
        </a>
        {% endif %}
      </div>

      <ul id="thumbs" class="{% if product.images.size == 1 %}visuallyhidden{% endif %}{% unless settings.main_image_display == 'Lightbox' %} switch{% endunless %}">
        {% for image in product.images %}
        <li>
          <a{% if settings.main_image_display == 'Lightbox' %} rel="fancybox"{% endif %} class="gallery" href="{{ image | product_img_url: 'original' }}" title="{{ image.alt | escape }}">
            <img src="{{ image | product_img_url: 'thumb' }}" alt="{{ image.alt | escape }}" />
          </a>
        </li>
        {% endfor %}
      </ul>
      
    </div><!-- /#product-gallery -->

  </div><!-- /#product -->

  {% if settings.productspg_related_products %}
  
    {% include 'related-products' %}

  {% elsif settings.productspg_featured_collection != blank %}

    {% assign collection = collections[settings.productspg_featured_collection] %}
    {% assign products   = collection.products %}

    {% if products.size > 0 %}
      <section class="diagonal-divider clearfix">

        {% unless settings.productspg_featured_collection_heading == blank %}
        <header class="section-details clearfix">
          <h1 class="section-title">{{ settings.productspg_featured_collection_heading | link_to: collection.url }}</h1>
        </header> 
        {% endunless %}

        <ul class="product-grid" id="secondary-grid">
          {% for product in products limit: settings.productspg_featured_limit %}
          <li class="{% cycle '', '', '', 'last-in-row' %}">
            {% include 'product-grid-item' %}
          </li>
          {% endfor %}
        </ul>      

      </section>
    {% endif %}

  {% endif %}

</div><!-- /#col-main -->

 

product-grid-item.liquid

<div class="product-grid-item " id="product-{{ product.variants.first.id }}">

  <a href="{{ product.url | within: collection }}" class="product-link" title="{{ product.featured_image.alt | escape }}">
    <span class="product-price{% if product.compare_at_price > product.price %} sale{% endif %}">
      {% if product.available %}
      {% if product.price_varies %} 
      <small>from</small> {{ product.price_min | money }}
      {% else %}
      {{ product.price_min | money }}
      {% endif %}
      {% if product.compare_at_price > product.price %}
      <small>was {{ product.compare_at_price | money }}</small>
      {% endif %}
      {% else %}
      Sold Out
      {% endif %}
    </span>
    <img src="{{ product.featured_image | product_img_url: 'medium' }}" class="product-photo" alt="{{ product.featured_image.alt | escape }}" />
  </a>
  
  <div class="product-information">
    <a href="{{ product.url | within: collection }}">{{ product.title }}</a>                    
  </div>    
          
</div>    

 

0 Likes
Astronaut
1890 1 393

You're looking for the product.template_suffix variable.

    {% unless product.template_suffix == 'Hidden-price' %}
    <span class="product-price{% if product.compare_at_price > product.price %} sale{% endif %}">
      {% if product.available %}
      {% if product.price_varies %} 
      <small>from</small> {{ product.price_min | money }}
      {% else %}
      {{ product.price_min | money }}
      {% endif %}
      {% if product.compare_at_price > product.price %}
      <small>was {{ product.compare_at_price | money }}</small>
      {% endif %}
      {% else %}
      Sold Out
      {% endif %}
    </span>
    {% endunless %}

I hope this helps.

1 Like
Shopify Partner
4 0 0

Perfect! Thank you very much for you help, 

0 Likes
Shopify Partner
4 0 0

I am back at it with the "related-products.liquid" template now. What's happening is the related products show the prices. I have tried using your code but it will not work because it is looking at the current product to see if it is using the Hidden-price template. If I go to the product that is NOT supposed to have the price, ALL of the related products do not have prices. Where if I go to one of the products that ARE supposed to have prices the related products all have prices even the ones that are not supposed to have them.

I guess I am sticking this in the wrong place... I am wrapping the price but it should probably be wrapping the loop. The code I used is below which is wrong (wrapping the image) and the full related-products.liquid code is below that. Thanks!

              {% unless product.template_suffix == 'Hidden-price' %}
              <span class="product-price">
                {% if prod.price_varies %} 
                <small>from</small> {{ prod.price_min | money }}
                {% else %}
                {{ prod.price_min | money }}
                {% endif %}
                </span>
              {% endunless %}

related-products.liquid

{% assign number_of_related_products_to_show = settings.productspg_featured_limit %}

{% capture number_of_related_products_to_fetch %}{{ number_of_related_products_to_show | plus: 1 }}{% endcapture %}

{% if collection == null or collection.handle == 'frontpage' or collection.handle == 'all' %}
{% assign found_a_collection = false %}
{% for c in product.collections %}
  {% if found_a_collection == false and c.handle != 'frontpage' and c.handle != 'all' and c.all_products_count > 1 %}
    {% assign found_a_collection = true %}
    {% assign collection = c %}
  {% endif %}
{% endfor %}
{% endif %}

{% if collection %}
  <section class="diagonal-divider clearfix">
    {% unless settings.productspg_featured_collection_heading == blank %}
    <header class="section-details clearfix">
      <h1 class="section-title">{{ settings.productspg_featured_collection_heading | link_to: collection.url }}</h1>
    </header> 
    {% endunless %}
    <ul class="product-grid clearfix">
    {% assign current_product_found = false %}
    {% for prod in collection.products limit: number_of_related_products_to_fetch %}
    {% if prod.title == product.title %}
       {% assign current_product_found = true %}
    {% else %}
       {% unless current_product_found == false and forloop.last %}
       <li{% cycle 'related': '', '', '', ' class="last-in-row"' %}>
         <div class="product-grid-item">
            <a href="{{ prod.url | within: collection }}" class="product-link" title="{{ prod.featured_image.alt | escape }}">
                <span class="product-price">
                {% if prod.price_varies %} 
                <small>from</small> {{ prod.price_min | money }}
                {% else %}
                {{ prod.price_min | money }}
                {% endif %}
                </span>
                <img src="{{ prod.featured_image | product_img_url: 'medium' }}" class="product-photo" alt="{{ prod.featured_image.alt | escape }}" />
            </a>  
            <div class="product-information">
                <a href="{{ prod.url | within: collection }}">{{ prod.title | escape | truncate: 45 }}</a>                    
            </div>  
          </div>
        </li>
       {% endunless %}
    {% endif %}
    {% endfor %}
    </ul>
  </section>
{% endif %}

 

0 Likes
Astronaut
1890 1 393

You need to make a small change to the code that you were using.  In the first line, change "product.template_suffix" to "prod.template_suffix".

              {% unless prod.template_suffix == 'Hidden-price' %}
              <span class="product-price">
                {% if prod.price_varies %} 
                <small>from</small> {{ prod.price_min | money }}
                {% else %}
                {{ prod.price_min | money }}
                {% endif %}
                </span>
              {% endunless %}

 

0 Likes
Tourist
3 1 1

I just wanted to come in here and thank @Alex135 for posting a solution to this issue. It worked for me!

0 Likes