How to disable/hide woocommerce single product page

I’m wondering how to remove the links on the shop page to the single product page. I simply want users to be able to click on the ‘add to cart’ button on the shop page. This will leave only the ‘Add to cart’ button available, so customers won’t be able to view the product page, but can still purchase the product. This can be helpful if your products don’t require much description, or you link to product pages elsewhere.

So Add this code in your theme’s functions.php file of your active child theme (or theme) and Save the file.

remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );

If you want to target only a specific category than take the following code and add this code in your theme’s functions.php file of your active child theme (or theme) and Save the file.

function remove_direct_link_to_product_page(){ 
   if ( is_product() && is_product_category(array('category-slug') ) ) { 
     remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 ); 
     remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 ); 
    } 
}

Leave a Comment

Scroll to Top