A lot of people are using WooCommerce to build their online shop nowadays but I’m sure not all of them are really using the add to cart functionality in woocommerce.
If you are one of them and are are curious how to disable or remove the Add to Cart button from WooCommerce products, we’re going to provide you with a little snippets.
As always, add this code to your theme’s functions.php file.
// Remove shoopping cart 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', 30 );
If you want to disable the Add to Cart button only for non-admin users, you use this instead:
// Remove shoopping cart for non-admin users / normal site visitors if ( ! current_user_can( 'administrator' ) ) { 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', 30 ); }