Skip to content

Instantly share code, notes, and snippets.

@harishankerr
Created April 17, 2020 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harishankerr/263a1807571c9ecb049f6f703d7c9df7 to your computer and use it in GitHub Desktop.
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
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