Remove price, Paynow and add to cart when price = 0 in Debut theme

Solved

Remove price, Paynow and add to cart when price = 0 in Debut theme

JCJackie
Tourist
9 0 3

Hi all,

 

I used the below script to remove the price when it is equal to 0, it works fine, however, i want to hide the add to cart and pay now in Debut, can anyone help?

 

<script>
function hidePrices(){
var prices = document.querySelectorAll('.price-item--regular');
if (!prices){return;}

for (var each of prices)
{ var price=each.textContent.trim();
if (price == '$0.00') {
each.closest('.price').remove();
}

}
}

hidePrices();
</script>

Accepted Solution (1)
DaisyVo
Shopify Partner
2848 343 401

This is an accepted solution.

Hi @JCJackie 

 

In order to fulfill your request, please follow these steps

 

Step 1: Go to Shopify Admin -> Online Store ->Theme -> Edit code
Step 2: Search file theme.liquid
Step 3: Insert this code above </head>

 

{% if product.price == 0 %}
{% style %}
form.product-form.product-form-product-template.product-form--payment-button-no-variants {
    display: none !important;
}
{% endstyle %}
{% endif %}

 

 

I hope this helps

 

Best,

 

Daisy

Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!

Avada SEO & Image Optimizer - The #1 SEO solution

View solution in original post

Replies 6 (6)

Moeed
Shopify Partner
6619 1789 2173

Hey @JCJackie 

 

Welcome to Shopify Community! Can you share your Store URL so I can have a look on it? Also, if you have password enabled then please share the password as well. Your cooperation would be greatly appreciated.

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


JCJackie
Tourist
9 0 3

https://www.theukulelestore.hk/en/products/give-thanks-%E5%85%8D%E8%B2%BBukulele-chord%E8%AD%9C

 

thanks @Moeed  i have removed the price, but also want to remove the "buy it now"  and "add to cart" button

 

Moeed
Shopify Partner
6619 1789 2173

Hey @JCJackie 

 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the following code in the bottom of the file above </body> tag

<style>
.product-form {
    display: none !important;
}
</style>

RESULT:

Moeed_0-1733389542367.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


JCJackie
Tourist
9 0 3

@Moeed i only want it to be hide when the price is 0 (which i already hide the price), and the button should be showing when the price is > 0

DaisyVo
Shopify Partner
2848 343 401

This is an accepted solution.

Hi @JCJackie 

 

In order to fulfill your request, please follow these steps

 

Step 1: Go to Shopify Admin -> Online Store ->Theme -> Edit code
Step 2: Search file theme.liquid
Step 3: Insert this code above </head>

 

{% if product.price == 0 %}
{% style %}
form.product-form.product-form-product-template.product-form--payment-button-no-variants {
    display: none !important;
}
{% endstyle %}
{% endif %}

 

 

I hope this helps

 

Best,

 

Daisy

Please let us know if our reply is helpful by giving it a Like or marking it as a Solution!

Avada SEO & Image Optimizer - The #1 SEO solution
JCJackie
Tourist
9 0 3

thanks @DaisyVo , it works