How to hide the price on $0 items

Solved
New Member
7 0 0

Hi,

I have a number of products that we are not allowed to sell online but can advertise that we sell them. We've had a few instances recently of customers trying to purchase these items.

Can you suggest a way to take the price off or hide th add to cart button ?

We are running the Deburt theme.

Here is an example of a product https://www.bed-post.co.uk/products/mlily-harmony-2000-ortho

Thanks

0 Likes

Success.

Shopify Staff
Shopify Staff
578 37 55

Hi, Lance!

Ted here from Shopify. :-) 

I was chatting with our Theme Support who've advised they can implement this change for you, as you are using the Debut theme. To do so, could you email support@shopify.com? When you do, you should receive an automated email back with a ticket number assigned. If you let me know what that ticket number is, I'll raise it further for you.

If there is anything else I can help you with, please let me know, I'm happy to help! 

Thanks a mill! 
Ted
 

Ted | Social Care @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes
New Member
7 0 0

Hi Ted,

I just recieved an empty emai back, no ticket number on it ?

Thanks

0 Likes
Shopify Staff
Shopify Staff
578 37 55

Hi, Lance!

We were able to grab that ticket from the queue for you and I believe our Theme Support have made those changes and emailed you back. Please let me know if there's anything else I can help you with. :-) 

-Ted

Ted | Social Care @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes
Shopify Partner
12 0 5

For anyone finding this thread on google at a later date - if you're comfortable editing the code on your theme, here's an explanation:

You pretty much just want to add an additional IF statement anywhere that Shopify usually displays the product's price. For me (using Supply theme), this is product-template.liquid (main product page), product-grid-item.liquid (product collection pages) and product-list-item.liquid (product collection pages). This may vary depending on your theme.

For product-template.liquid, I don't want the price or add to cart button displayed, so I find that section of html. To find it, I scrolled through looking for a mention of price and found:

<ul class="inline-list product-meta">
        <li>
          <span id="productPrice-{{ section.id }}" class="h1">
            {% include 'price' with variant.price %} 
          </span><small> including VAT</small>
        </li>

So, that <span> is where the price is displayed. But because it's inside some list tags, I have to make sure I go to the start of that section so it can be cleanly removed (instead of a chunk of code being taken from the middle, potentially leaving some issues behind). The <span> is inside of a <li> which is always inside of a <ul> - so <ul> is as high as I have to go. So this is where I'll insert the start of my IF statement, like so:

{% if variant.price > 0 %}
      <ul class="inline-list product-meta">
        <li>
          <span id="productPrice-{{ section.id }}" class="h1">
            {% include 'price' with variant.price %} 
          </span><small> including VAT</small>
        </li>

We've found the start of the section we want hidden, now we just need the end. We're looking for the code responsible for the "Add to cart" button, this will be inside of a <form> tag like this:

<form action="/cart/add" method="post" enctype="multipart/form-data" id="addToCartForm-{{ section.id }}">

Now we have the <form> that controls the cart, we want to make sure we end our IF statement after this form. So, look for the </form> that ends this block and add {% endif %} afterwards. Like this:

</form>
{% endif %}

The process will need to be repeated for the other liquid templates but the code you're looking for will be very similar in each.

So, what we've just done is told Shopify to check the price of the product and if that price is more than £0 then it can go ahead and display a price and an add to cart button (and reviews, or anything else within that IF statement). If the price is £0 then Shopify will now skip the code within that IF statement.

1 Like
New Member
7 0 0

Hi,

Thanks for all your help on this, much appreciated.

One further question related to this. Would it be possible to hide the 'add to cart' button on $0 items as well ?

Many thanks

0 Likes
New Member
1 0 0

Hello Ted,

Is it possible to hide the prices on certain items and leave the prices on others?

Regards,

Batu

0 Likes
New Member
3 0 0

Can you help me? I'm using the minimal theme. I can't find where to start the code. 

0 Likes
Shopify Staff
Shopify Staff
578 37 55

Hi folks, 

 

The Debut theme has been upgraded since and the above code may not apply correctly to the theme anymore. Please always make sure to duplicate or back up your theme before making any coding changes to your store. You should be able to do so as shown in this guide


Our Theme Support would be happy to review your request with some Design Time. For them to take a look, please contact us directly either via live chat, email, phone or through our social media support channels here for an immediate response. 

 

If there is anything else I can help you with, please let me know, I'm happy to help!

All the best,

Ted | Social Care @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

0 Likes