Hide price for out of stock products on collections page - Warehouse Theme

mondo15
Shopify Partner
6 0 0

Hi!

I need help to hide the price for out of stock items on a collection page - Warehouse Theme. 

Many items we stock are Priced On Application, so are not technically 'Out of Stock', but their inventory will always be '0'. Prices can change for the items, so we do not want a fixed price listed on the site.

 

I have managed to set up a product page template for these items where I have removed the price and changed the 'add to cart' button to an email link, but I am struggling to remove price for specific products on collection page, and search function. Closest I have got is removing all the prices completely.

 

I believe the code for it is in Snippet 'product-item.liquid' in this section:

 

  <div class="product-item__info"> 
    <div class="product-item__info-inner">
      {%- capture price_list -%}
        <div class="product-item__price-list price-list">
          {%- if product.price < product.compare_at_price -%}
            {%- if product.compare_at_price_varies -%}
              {%- capture price_min -%}<span>{{ product.price_min | money_without_trailing_zeros }}</span>{%- endcapture -%}
              {%- capture price_max -%}<span>{{ product.price_max | money_without_trailing_zeros }}</span>{%- endcapture -%}
              <span class="price price--highlight">{{ 'collection.product.from_price_html' | t: price_min: price_min, price_max: price_max }}</span>
              <span class="price price--compare">{{ product.compare_at_price_min | money_without_trailing_zeros }}</span>
            {%- else -%}
              <span class="price price--highlight">{{ product.price | money_without_trailing_zeros }}</span>
              <span class="price price--compare">{{ product.compare_at_price | money_without_trailing_zeros }}</span>
            {%- endif -%}
          {%- elsif product.price_varies -%}
            {%- capture price_min -%}<span>{{ product.price_min | money_without_trailing_zeros }}</span>{%- endcapture -%}
            {%- capture price_max -%}<span>{{ product.price_max | money_without_trailing_zeros }}</span>{%- endcapture -%}
            <span class="price">{{ 'collection.product.from_price_html' | t: price_min: price_min, price_max: price_max }}</span>
          {%- else -%}
            <span class="price">{{ product.price | times:1.20 | money_without_trailing_zeros }} Inc-Vat</span>
          	<span>{{ product.price | money_without_trailing_zeros }} Ex-Vat</span>
          {%- endif -%}
        </div>


        {%- if product.selected_or_first_available_variant.unit_price_measurement -%}
          <div class="product-item__price-info">
            <div class="unit-price-measurement">
              <span class="unit-price-measurement__price">{{ product.selected_or_first_available_variant.unit_price | money_without_trailing_zeros }}</span>
              <span class="unit-price-measurement__separator">/ </span>

              {%- if product.selected_or_first_available_variant.unit_price_measurement.reference_value != 1 -%}
                <span class="unit-price-measurement__reference-value">{{ product.selected_or_first_available_variant.unit_price_measurement.reference_value }}</span>
              {%- endif -%}

              <span class="unit-price-measurement__reference-unit">{{ product.selected_or_first_available_variant.unit_price_measurement.reference_unit }}</span>
            </div>
          </div>
        {%- endif -%}
      {%- endcapture -%}

 

 

I cannot seem to find the correct solution to get '.product-item__price-list price-list to display none or visibility hidden' if inventory is 0.

 

Also, looking to do this without an app as well. Im fairly competent with code, but any help would be great!

TIA

Replies 2 (2)
Phoenixlab
Shopify Partner
3 0 0

Hello!

 

You can condition for check product is available or not, try this once:

 

{% if product.available %}

<YOUR CODE FOR PRICE/>

{% endif %}

 

Thanks!

mondo15
Shopify Partner
6 0 0

Hi!

 

Thanks for your response, and time.

 

I initially tried to wrap the pricing code in an if available tag, but had no joy with it.

 

I also tried a 'less than' operator tag, and they all disappeared. So I'm in the right place for it/ on the right track, just cant find the correct logic to achieve what I want it to.

 

Thanks again!