Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Shop page on Woocommerce to protect categories

Im trying to disable "shop" page in Woocommerce. Basically im creating a shop theme to sell prints and image downloads for a photographer.

Because i need to create private galleries i created a custom post type where i use the woocommerce category shortcode to show products and then i password protect the post type.

This is a workaround for password protecting the woocommerce categories (if someone knows a better one please explain).

The problem is that is someone goes to /shop they will all products, including the "protected ones". So i need to disable the shop page and i need to do it programmatically on my theme functions. Any thoughts?

like image 548
chifliiiii Avatar asked Oct 03 '12 20:10

chifliiiii


People also ask

How do I hide categories from being displayed on shop page WooCommerce?

From the admin panel, go to WooCommerce > Product Visibility > Global visibility tab and select the product and category you want to hide.

How do I hide categories on my shop page?

To set up the plugin's settings, log in to your WordPress admin panel and navigate to WooCommerce > Settings > Products > Protected categories . Untick both boxes next to the Category Visibility option if you wish to hide your protected product categories from your store.


1 Answers

To disable the shop page, copy over the archive-product.php file from the /wp-content/plugins/woocommerce/templates/archive-product.php and put in /wp-content/themes/{Your Theme}/woocommerce/archive-product.php

Open up the file and overwrite everything in file with the following code below:

<?php
global $wp_query;

$wp_query->set_404();
status_header(404);

get_template_part('404');

Save the file, and now your Shop page is gone and replaced with a 404 Page!

like image 162
Solomon Closson Avatar answered Nov 02 '22 07:11

Solomon Closson