DEV Community

alexanderbiscajin
alexanderbiscajin

Posted on

Hide or Remove Add to Cart Button In WooCommerce Store

This Post was originally published on WPblog Hide or Remove Add To Cart Button In WooCommerce Store.

I have seen that most of the store owners got confused while removing or disable the add to cart button. Now for any shop page or product you can remove the the add 2 cart button. You just have to follow these simple steps. In woocommerce.php (located wp-content/plugins/woocommerce)


function WpBlog() {
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();
}

After that refresh shop page and you will see that the button will be removed from the page.

You can also remove add to cart button for specific product pages.

Add this code to the functions.php (located in the theme folder):


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);
}

Top comments (5)

Collapse
 
alexbang profile image
Frodo

Your code does not work in the new version woocommerce.
Here is the working version:

add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );

function remove_add_to_cart_buttons() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
We used it on our website aliexpress-lafa.ru/katalog/. Everything works great!

Collapse
 
jameskendy profile image
jameskendy

I am having an unexpected error while removing add to cart button on my product page. I am using this tutorials for my reference code wpitech.com/hide-disable-add-to-ca... . 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();

Collapse
 
waqasnayyer1 profile image
Waqas Nayyer

You can use this free plugin to remove add to cart button: wordpress.org/plugins/remove-add-t...

Collapse
 
datmt profile image
Mạnh Đạt

If you prefer CSS, this is the way: binarycarpenter.com/the-easiest-wa...

Some comments may only be visible to logged-in visitors. Sign in to view all comments.