Hide or Remove "add to cart" button for specific products

New Member
14 0 0

Hi,

I use Icon Theme and am having trouble editing the theme. I would like to hide or remove the "add to cart" button for specific products. I understand how to make a new template for products but I can't find the text in there where it says add to cart in order to edit it. So I was wondering if you had to do it a different way for the Icon Theme?

Thanks,

Ginger

0 Likes
Shopify Staff
Shopify Staff
283 0 45

Hi Ginger,

Hugh here from Shopify. In the product template, you will want to look for this line of code, and remove it, to get rid of the add to cart button:

<input type="submit" name="button" class="add" id="AddToCart" value="Add to Cart">

That should do it! Please let me know if you had any other questions about this!

Hugh

Happy selling! :)
0 Likes
New Member
6 0 0

Hugh,

What if I want to hide the button just for products with a $0 value? This is what I have so far, but I can't figure it out. I don't want the variants to be crossed out as a result of me making 0 stock, but I'm ok with the "Sold Out" button appearing because I will just change it to "Not Available". I just want the "Add to Cart" button to go away for products with $0 price.

<div class="product-single__add-to-cart">
                <button type="submit" name="add" id="AddToCart" class="btn"{% unless product.available %} disabled="disabled"{% endunless %}>
                  <span id="AddToCartText">
                    {% if product.available %}
                      {{ 'products.product.add_to_cart' | t }}
                    
                    {% else product.price == 0 %}
              {{ 'products.product.sold_out' | t }}
              
                    
                    {% else %}
                      {{ 'products.product.sold_out' | t }}
                    {% endif %}
                  </span>
                </button>
              </div>
              

 

0 Likes
New Member
3 0 0

If you want to hide or remove add to cart button for specific products then you have to put this code in functions.php.

add_filter('woocommerce_is_purchasable', 'wpblog_specific_product');

function wpblog_specific_product($purchaseable_product_wpblog, $product) {

return ($product->id == specific_product_id (512) ? false : $purchaseable_product_wpblog);

}

Reference : Hide add to cart button in WooCommerce

 

0 Likes
Tourist
18 0 1

Hello ,

Remove add to cart button on specific products , you have to use customization product template.

you can select this customize product template to specific products that you dont want to show add to cart button.

This article will help you to understand this concept -

https://help.shopify.com/themes/customization/products/features/get-customization-information-for-pr...

Vijendra Sisodiya Founder of VsisodiyaDesign
0 Likes
Highlighted
New Member
1 0 0

I am having an unexpected error while removing add to cart button on my product page. I am using this tutorial for my reference code https://wpitech.com/hide-disable-add-to-cart-button-in-woocommerce-store/ . Is there any other way to hide add to cart button. This is the code that I am using to hide add to cart button on my product page

function flav() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
return WooCommerce::instance();

0 Likes