Reputation: 2775
I have difficulty doing this even after following instructions of how to do it. I don't know if the structure of woocommerce
have changed since the below snippet was given.
Below is the code I tried using to remove the Add to cart
button in the Homeapage
and Shop page
.
Mind you, this was pasted in the Theme Functions (functions.php)
and I use MyStile Theme
.
I was able to remove the Add to Cart
button from the single page but not the homepage and shop page
.
Code
function remove_loop_button(){
remove_action('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
}
add_action('init', 'remove_loop_button');
Thanks for your help in advance.
Upvotes: 1
Views: 631
Reputation: 26
You can use following code. Put it in your functions.php
:
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 );
To Remove “Add to Cart” button all you need to do is paste the following lines of code in your functions.php
file located inside your theme’s directory.
//remove "Add to Cart" button on product listing page in WooCommerce
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' );
}
Upvotes: 1