How can I hide a product's price when it's set to zero using liquid?

Hi Everyone!

I have been back and forth trying to hide the price section when a product price is set to zero. I am using the Warehouse theme and have played around with different codes, but nothing seems to work. Here is a screenshot of what I would like to hide

I Under snippets, I have the following code:

{%- capture price_list -%}
{%- if product.price < product.compare_at_price -%} {%- if product.price_varies -%} {%- capture price_min -%}{{ product.price_min | money }}{%- endcapture -%} {%- capture price_max -%}{{ product.price_max | money }}{%- endcapture -%} {{ 'product.general.sale_price' | t }} {{- 'collection.product.from_price_html' | t: price_min: price_min, price_max: price_max -}} {{ 'product.general.regular_price' | t }} {{- product.compare_at_price_min | money -}} {%- else -%} {{ 'product.general.sale_price' | t }} {{- product.price | money -}} {{ 'product.general.regular_price' | t }} {{- product.compare_at_price | money -}} {%- endif -%} {%- elsif product.price_varies -%} {%- capture price_min -%}{{ product.price_min | money }}{%- endcapture -%} {%- capture price_max -%}{{ product.price_max | money }}{%- endcapture -%} {{ 'product.general.sale_price' | t }} {{- 'collection.product.from_price_html' | t: price_min: price_min, price_max: price_max -}} {%- else -%} {{ 'product.general.sale_price' | t }} {{- product.price | money -}} {%- endif -%}

I have tried unless/if statements to hide the code when prices are “0” with no luck. Am I looking in the right snippet? Any help would be greatly appreciated!!!

-TFT

Hi @TFT-MICRO in the following video guide I hide out the quantity and variant select, for your case delete the price block as shown in the video. Then go to every product which has zero price, from the right sidebar select this new template.

1 Like

My theme (Warehouse) does not give the ability to edit these fields. I think I will need to add some code to accomplish this.

please share the code of main-product.liquid file

The product.liquid file points to the product.template file which points to the code I originally posted.

I figured out a solution. I added these tags to the product-info.liquid file:

{%- unless product.price == 0 -%}
{% endunless %}


        

      {%- unless product.price == 0 -%}
          {{ 'product.form.price' | t }}
        {% endunless %}
          

            

      {%- unless product.price == 0 -%}
              {%- if selected_variant.compare_at_price > selected_variant.price -%}
                
                  {{ 'product.general.sale_price' | t }}
                  {{- selected_variant.price | money -}}
                

                
                  {{ 'product.general.regular_price' | t }}
                  {{- selected_variant.compare_at_price | money -}}
                
              {%- else -%}
                
                  {{ 'product.general.sale_price' | t }}
                  {{- selected_variant.price | money -}}
                
              {%- endif -%}
        {% endunless %}
            

            
              

                
                / 

                
                  {{- selected_variant.unit_price_measurement.reference_value -}}
                

                {{ selected_variant.unit_price_measurement.reference_unit }}
              

            

       {%- unless product.price == 0 -%}
            {{- form | payment_terms -}}
         {% endunless %}
1 Like