Created
April 17, 2020 07:08
-
-
Save harishankerr/263a1807571c9ecb049f6f703d7c9df7 to your computer and use it in GitHub Desktop.
Hide Add to cart button in the Shop page, Home page, Category Page, and in Related Products
This file contains 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() { | |
/*Removes add to cart buttons from shop, category, and home pages */ | |
if( is_product_category() || is_shop() || is_front_page()) { | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); | |
} | |
/*Removes add to cart buttons from related products section */ | |
global $woocommerce_loop; | |
if ( is_product() && $woocommerce_loop['name'] == 'related' ) { | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment