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?
From the admin panel, go to WooCommerce > Product Visibility > Global visibility tab and select the product and category you want to hide.
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.
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!
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