Sandeep Kumar Mishra
Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

Running a WooCommerce online store? Obviously, you want that your customers can easily add your products to their shopping cart, isn’t it? Then why would you want to hide the ‘Add to Cart’ button in WooCommerce? Let us first understand why this need might arise and then learn how to go about it.
There are plenty of instances when you would want to hide the WooCommerce ‘Add to Cart’ button. Here are a few of them:
Now that we have listed the reasons, let’s discuss why a simple Google search will not provide the answer to the question – “How do you hide the ‘Add to Cart’ button on WooCommerce?”
Try searching for the keywords, “remove add to cart button WooCommerce” on Google – and you will find a couple of credible search results. Most of these search results will guide you to remove the following functions using the “Remove Action” function:
However, doing this will disable the ‘Add to Cart’ button on your WooCommerce website entirely (on all pages). The first action above effectively disables the “Add to Cart” button on a particular product page, while the second action implements the same outcome on the shop page.
Another major problem with this action is that besides hiding the “Add to Cart” button, it can also remove some WooCommerce template files, which is unnecessary. We would recommend that before reusing this “Remove Action” code, first understand what each line of code does – and then go ahead if required.
Instead of using this function, there are far simpler and safer ways on WooCommerce to hide the ‘Add to Cart’ button. Let’s discuss them in the following sections.
Here is how you can hide the ‘Add to Cart’ button the right way for each of the following cases:
if ( ! $product->is_purchasable() ) {
return;
}
// For a specific product, override the is_purchasable to false
if ( $product->get_id() == 1234 ) { // Replace 1234 with your product ID
$product->set_is_purchasable(false);
}
.
add_filter( 'woocommerce_is_purchasable', 'custom_disable_add_to_cart_button', 10, 2 );
function custom_disable_add_to_cart_button( $is_purchasable, $product ) {
// Replace '1234' with the ID of the product you want to disable the 'Add to Cart' button for
if ( $product->get_id() == 1234 ) {
return false;
}
return $is_purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'hide_add_to_cart_for_guests', 10, 2 );
function hide_add_to_cart_for_guests( $is_purchasable, $product ) {
// Check if the user is not logged in
if ( ! is_user_logged_in() ) {
// Set the product as unpurchasable for guests
return false;
}
// Allow the "Add to Cart" button for logged-in users
return $is_purchasable;
}
add_filter( 'woocommerce_is_purchasable', 'remove_add_to_cart_for_specific_roles', 10, 2 );
function remove_add_to_cart_for_specific_roles( $is_purchasable, $product ) {
// Get current user role
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
$user_roles = $user->roles;
// Check if the user has the 'administrator' role
if ( in_array( 'administrator', $user_roles ) ) {
return false; // Disable 'Add to Cart' for administrators
}
}
return $is_purchasable; // Allow 'Add to Cart' for other roles
}
add_action( 'wp', 'disable_add_to_cart_for_selected_categories' );
function disable_add_to_cart_for_selected_categories() {
if ( is_product_category( 'laptops' ) ) { // Replace 'laptops' with your category slug
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
}
This action will also replace the “Cart” button with the “Read more…” button till the product release date.
add_filter( 'woocommerce_is_purchasable', 'disable_add_to_cart_for_date_range', 10, 2 );
function disable_add_to_cart_for_date_range( $is_purchasable, $product ) {
// Set the release date (YYYY-MM-DD format)
$release_date = '2024-12-01';
$current_date = date( 'Y-m-d' );
// Check if the current date is before the release date and if the product ID matches
if ( $current_date < $release_date && $product->get_id() == 1234 ) { // Replace 1234 with your product ID
return false; // Disable "Add to Cart"
}
return $is_purchasable; // Allow "Add to Cart" for other conditions
}
Conclusion
As discussed, there are multiple cases where you need to hide, remove, or disable the “Add to Cart” button on your WooCommerce store. To create a positive shopping experience for your customers, you can further customize your “Add to Cart” button in many ways.
With its expertise in WooCommerce development, WePlugins can provide a wide variety of services to help you build a great website. Our dedicated and highly experienced WordPress team has been doing coding and plugin development since the year 2012. Here is an informative blog on how to implement WooCommerce shipping based on zip code.
We can help in developing an entire WordPress website or even performing major bug fixes. Register today on the WePlugins website or drop us a message with your name and email address.
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.