How would we go about disabling the single product page for specific products?
For example, we have some products that have product variations. In this case we are using the single product page. But for the products that do not have variations we simply use an add to cart link on the landing pages and skip the single product page that just adds an extra step for the customer.
I found this post which outlines how to disable ALL single product pages. But I would like to target the pages that are disabled. Either by product number or perhaps product listing type ie. variable, non variable.
What is the best way to go about doing this, without breaking WooCommerce or causing SEO issues?
To clarify: by disabled I mean remove the link to the page from areas like the shopping cart etc.
2
Answers
You can add if statement around return false. You can either check for product (page) id or I would add tag (or category or custom field) to these and then in if statement you can check for this tag and if its there you return false;
In the following functions, you will have to define one or many product IDs inside the code.
This first hooked function will remove the product from product catalog:
To remove the link from cart items in cart page, you can use the following
Code goes in function.php file of your active child theme (or active theme). Tested and works.