I am trying to hide the single product detail page on my wordpress-woocommerce site. How can i achieve this without breaking woocommerce functionality?
You can use the 'Links' option to remove the product title link from the table. That way, customers won't be able to access the single product page.
From the admin panel, go to WooCommerce > Product Visibility > Global visibility tab and select the product and category you want to hide. This will hide the product and/or category from guests and all registered customers irrespective of their role.
To do this, go to the Products tab in your WordPress dashboard and click on Tags. Then, click on the Edit link next to the tag that you want to hide. In the Visibility section, select Hidden. Once you save your changes, the tag will be hidden from all products that have it applied.
Put it in functions.php
//Removes links
add_filter( 'woocommerce_product_is_visible','product_invisible');
function product_invisible(){
return false;
}
//Remove single page
add_filter( 'woocommerce_register_post_type_product','hide_product_page',12,1);
function hide_product_page($args){
$args["publicly_queryable"]=false;
$args["public"]=false;
return $args;
}
You can remove the anchor generated on shop page which would never redirect user to single page. For that, you have to paste this code in your functions.php file.
remove_action(
'woocommerce_before_shop_loop_item',
'woocommerce_template_loop_product_link_open',
10
);
This code will remove link but, after that you have to remove anchor closing tag as well just it doesn't break your html
remove_action(
'woocommerce_after_shop_loop_item',
'woocommerce_template_loop_product_link_close',
5
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With