Last active
September 20, 2021 23:53
-
-
Save rynaldos-zz/560c621714b9680433cddf18e6a50305 to your computer and use it in GitHub Desktop.
[WooCommerce] Hide "add to cart" button on certain product categories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 ); | |
function remove_add_to_cart_buttons() { | |
// replace a_category and another_category with the slugs of the categories you'd like to have the button removed from | |
if( is_product_category( array( 'a_category', 'another_category'))) { | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); | |
} | |
} | |
// Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this code
Reference : https://www.damiencarbery.com/2020/03/remove-add-to-cart-button-conditionally/