I've removed Add to Cart button from Shop and Category pages, but how about Related Products section that is below a product page? The code below doesn't work for that.
function remove_add_to_cart_buttons() {
if( is_product_category() || is_shop()) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
}
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 10 );
You could try using custom CSS as below. Put it under Appearance -> Customizer -> Custom CSS under your admin panel.
.woocommerce ul.products li.product a.button {
display: none;
}
Here's the code for the same:
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 );
The reason being that the 'Add to Cart' button is displayed on these two actions.
function woocommerce_template_single_add_to_cart()
{
global $product;
do_action( 'woocommerce_' . $product->product_type . '_add_to_cart' );
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.