Hide price only for products priced at $0 (not just sold out).

Solved

Hide price only for products priced at $0 (not just sold out).

ksinclairart
Visitor
2 0 0

Is there a way to hide the price on a product card when the price is set to $0? Across the entire site?

 

I found this question/answer to hide the price if the quantity is zero (sold out) and it worked:

https://community.shopify.com/c/shopify-design/dawn-theme-hide-price-of-out-of-stock-items/m-p/18458...

Is there a way to modify that code snip for the theme.liquid page to be "if product price is 0", not "sold out"?

 

<style> .price.price--sold-out { display: none; } </style>

Accepted Solution (1)

Taknify
Shopify Partner
274 19 29

This is an accepted solution.

Go to price.liquid assuming you are on dawn theme. 
Then, 
Add a condition on price__regular  div. 
You can add whatever logic you want on it. 

Taknify_1-1688688367269.png


Results: 
My Tuxedo doesn't show price because the price is $0.

Taknify_2-1688688411403.png

 

 

Let me know if you have further questions or need help on anything else. 

Need to tweak your store for Black Friday? Simply, send me a message.

View solution in original post

Replies 12 (12)

Taknify
Shopify Partner
274 19 29

This is an accepted solution.

Go to price.liquid assuming you are on dawn theme. 
Then, 
Add a condition on price__regular  div. 
You can add whatever logic you want on it. 

Taknify_1-1688688367269.png


Results: 
My Tuxedo doesn't show price because the price is $0.

Taknify_2-1688688411403.png

 

 

Let me know if you have further questions or need help on anything else. 

Need to tweak your store for Black Friday? Simply, send me a message.
ksinclairart
Visitor
2 0 0

Wonderful, this worked perfectly!  I wasn't sure what to write (or where to put it).

 

You were correct - Dawn theme.  I was able to easily locate the price.liquid file and add the code you highlighted + endif section at the end.  Thank you so much!

Taknify
Shopify Partner
274 19 29

I'm glad that was what you wanted. Again, don't hesitate to reach out to me if you have further issues down the road. 
Taknify
Tweek your store

Need to tweak your store for Black Friday? Simply, send me a message.
SASCustoms
Visitor
1 0 1

Hey @Taknify Can you help me with a different solution approach for the same code you shared ? 

 

1, hide the price of the product when it is "zero" from both the product card and product details page , Also remove the add to cart button and show a different button with a custom link ?  Can you help me for this ? 

 

 

amirasvanity
Excursionist
13 1 1

I'm trying to do the same. Will let you know if I come up with a solution. 

nicebunsbaking
Visitor
2 0 0

Hi, can you specifically paste what to write if I don’t want to display a product price set at $0? I copied exactly what you wrote here and it’s not working. I have the dawn theme

Taknify
Shopify Partner
274 19 29

Do you mind sending me a message with your store name so I can take a look?

Thanks,
Taknify

Need to tweak your store for Black Friday? Simply, send me a message.
Declan
Visitor
1 0 0

Hi, 

 

I've tried adding the code to the price.liquid as well, but unfortunately this isn't working for me either. 

So I have collections where some products will have no price (price = £0), but others will have a price. The ones with price = £0 will need a "request code" button instead of "add to cart". 

we work with the theme Dawn. 

 

Thanks

tradewindow
Visitor
2 0 0

I finally figured it out!!!

Green = New Code 

Blue = Existing Code

{% if product.price > 0 %}

<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span>
<span class="price-item price-item--regular">
{{ money_price }}
{% endif %}
</span>

Monique_B
Shopify Partner
7 0 1

Is there someone who knows where to add it in the Focal theme?

Taknify
Shopify Partner
274 19 29

Hello,

Since this is a paid theme, I am not able to view the code to make changes. If you can provide the code or something so I can check, I can likely help you further on it. 


Need to tweak your store for Black Friday? Simply, send me a message.

tradewindow
Visitor
2 0 0

nothing changes ... tried for 2 days (your code seems cut off or incomplete anyway)
bare in mind most people here are complete newbies ... so i cut and copy your code and nothing happens 

<div class="price__regular">

{% if product.price > 0 %}
<span class="visually-hidden visually-hidden--inline"></span>
<span class="price-item price-item--regular">
{{ money_price }}
</span>
{% endif %}

{%- if product.quantity_price_breaks_configured? -%}
{%- if show_compare_at_price and compare_at_price -%}
{%- unless product.price_varies == false and product.compare_at_price_varies %}
<span class="visually-hidden visually-hidden--inline">
{{- 'products.product.price.regular_price' | t -}}
</span>
<span>
<s class="price-item price-item--regular variant-item__old-price">
{% if settings.currency_code_enabled %}
{{ compare_at_price | money_with_currency }}
{% else %}
{{ compare_at_price | money }}
{% endif %}
</s>
</span>
{%- endunless -%}
{%- endif -%}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span>
<span class="price-item price-item--regular">
{{- 'products.product.volume_pricing.price_range' | t: minimum: money_price_min, maximum: money_price_max -}}
</span>
{%- else -%}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span>
<span class="price-item price-item--regular">
{{ money_price }}
</span>
{%- endif -%}
</div>
<div class="price__sale">
{%- unless product.price_varies == false and product.compare_at_price_varies %}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.regular_price' | t }}</span>
<span>
<s class="price-item price-item--regular">
{% if settings.currency_code_enabled %}
{{ compare_at_price | money_with_currency }}
{% else %}
{{ compare_at_price | money }}
{% endif %}
</s>
</span>
{%- endunless -%}
<span class="visually-hidden visually-hidden--inline">{{ 'products.product.price.sale_price' | t }}</span>
<span class="price-item price-item--sale price-item--last">
{{ money_price }}
</span>
</div>
<small class="unit-price caption{% if product.selected_or_first_available_variant.unit_price_measurement == nil %} hidden{% endif %}">
<span class="visually-hidden">{{ 'products.product.price.unit_price' | t }}</span>
<span class="price-item price-item--last">
<span>{{- product.selected_or_first_available_variant.unit_price | money -}}</span>
<span aria-hidden="true">/</span>
<span class="visually-hidden">&nbsp;{{ 'accessibility.unit_price_separator' | t }}&nbsp;</span>
<span>
{%- if product.selected_or_first_available_variant.unit_price_measurement.reference_value != 1 -%}
{{- product.selected_or_first_available_variant.unit_price_measurement.reference_value -}}
{%- endif -%}
{{ product.selected_or_first_available_variant.unit_price_measurement.reference_unit }}
</span>
</span>
</small>
</div>

( https://www.cre8-health.co.uk/ )