Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable/hide woocommerce single product page?

I am trying to hide the single product detail page on my wordpress-woocommerce site. How can i achieve this without breaking woocommerce functionality?

like image 514
wonder Avatar asked May 26 '17 09:05

wonder


People also ask

How do I turn off WooCommerce single product page?

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.

How do I hide specific Products in WooCommerce shop?

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.

How do I hide the tags on a WordPress product page?

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.


2 Answers

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;
}
like image 177
Vitaly Gritsienko Avatar answered Nov 08 '22 05:11

Vitaly Gritsienko


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
);
like image 42
BeeFaauBee Avatar answered Nov 08 '22 03:11

BeeFaauBee