Want to remove add to cart and buy now button when products sold out.

Solved

Want to remove add to cart and buy now button when products sold out.

Gaurav24
Visitor
3 0 1

Want to remove add to cart and buy now button when products sold out.

 

Here is my website products link: https://cameraclub.in/products/fujifilm-gf-20-35mm-f4-r-wr

Please help me out how can I do it.

Accepted Solution (1)

theycallmemakka
Shopify Partner
1813 439 474

This is an accepted solution.

 

Hi @Gaurav24 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code just above tag </body>

 

<style>
.product-form__submit[disabled], dynamic-checkout[disabled] {
    display: none;
}

</style>

makkaomakka_0-1701340659565.png

If you require further help to optimize your store, please don’t hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!

 

Best Regards,
Makka

 

Support Me: Buy me a Coffee


For quick response - Message Me


Ping me at: theycallmemakka@gmail.com

View solution in original post

Replies 3 (3)

theycallmemakka
Shopify Partner
1813 439 474

This is an accepted solution.

 

Hi @Gaurav24 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code just above tag </body>

 

<style>
.product-form__submit[disabled], dynamic-checkout[disabled] {
    display: none;
}

</style>

makkaomakka_0-1701340659565.png

If you require further help to optimize your store, please don’t hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!

 

Best Regards,
Makka

 

Support Me: Buy me a Coffee


For quick response - Message Me


Ping me at: theycallmemakka@gmail.com

Gaurav24
Visitor
3 0 1

Thank you @theycallmemakka 
It's working

aditya58singh
Shopify Partner
34 2 6

Hi @Gaurav24 

 

  1. Go to your Shopify Admin
  2. Click on 'Online Store' and then 'Themes'.

Find your current theme, click on 'Actions', and then select 'Duplicate'. This will create a backup of your theme.

1 Approach Edit Your Theme Code

 

In the editor, locate the theme.liquid file. This file is usually found in the "Layout" directory.

Scroll down to the bottom of the theme.liquid file and locate the closing </body> tag.

 

<style>
.product-form__submit[disabled], .dynamic-checkout__submit[disabled] {
display: none;
}
</style>

 

This CSS targets the submit buttons in the product form (product-form__submit) and dynamic checkout buttons (dynamic-checkout__submit) that are disabled (typically when a product is sold out).

 

2 Approch Implement the Conditional Logic

 

Locate the product template file. This is usually named product-template.liquid, product.liquid, or something similar, and can be found in the 'Sections' or 'Templates' folder.

 

Find the section of the code where the "Add to Cart" and "Buy Now" buttons are added. This section typically includes HTML input or button elements with types like submit or classes/ids like add-to-cart, buy-it-now, etc.

 

{% if product.available %}
  <!-- Existing code for Add to Cart and Buy Now buttons -->
  <input type="submit" name="add" class="btn" value="Add to Cart">
  <button type="button" class="buy-it-now btn">Buy it Now</button>
{% else %}
  <p>This product is currently out of stock.</p>
{% endif %}
- Helpful? Like and Accept a solution.
- Cart Drawer Upsell & Free Gift Boost conversions & AOV with upsell-cross sell, free gifts & add-ons with customizable cart drawer.

Sales Countdown Timer Bar create urgency with count down timer, navigation menu with images and lot more.