• For the past couple of hours I’ve been trying to do something that I thought is easy, but I’m no longer sure that this is the case.

    In the settings of woocommerce we can select a page that will act as the “start page” of our shop. It’s an archive that lists all products in the shop in a predefined order.

    I want to create a site where there are 3 menu items:

    New | All Products | Sale

    Basically the 3 pages should behave more or less the same.
    On the left I want to have filters – categories, price, color etc and on the right I want to show the products.

    The only difference between the 3 views is that on new – I only show new products and the categories that don’t have new products shouldn’t appear.

    Under sale I only list the items that are marked for sale and the categories that don’t contain such items should not appear.

    I tried creating a new page and added a column with and on the left published categories and on the right the sales product block. The sales product block only shows the items on sale, but the categories block shows all the categories I have and clicking on any of them doesn’t filter the sales items, but loads the main shop page.

    Is there any way to achieve this?
    As a visual example – orsay.de has the same thing:
    https://www.orsay.com/de-de/neuheiten/
    https://www.orsay.com/de-de/produkte/
    https://www.orsay.com/de-de/sale/

Viewing 8 replies - 1 through 8 (of 8 total)
  • There can be only one shop page. For your other pages, see the available shortcodes which can be crafted to show a particular subset of products:
    https://docs.woocommerce.com/document/woocommerce-shortcodes/

    Thread Starter dsd87

    (@dsd87)

    Thanks for the reply. Unfortunately with shortcodes I can only display the products – sales, new, but I can’t have any kind of filtering on that page…

    That’s a bummer.

    Thread Starter dsd87

    (@dsd87)

    Okay, I think that I’m getting there. For others that have the same requirement here is what I did.

    I created 3 menus
    shop – /shop
    new-products – /shop?new=1
    sales – /shop?sale=1

    I created a plugin that intercepts the woocommerce_product_query

    function cjwc_product_query( $q ){
    
        $uri = $_SERVER['REQUEST_URI'];
    
        if(strstr($uri, 'sale=1')) {
    	    $product_ids_on_sale = wc_get_product_ids_on_sale();
    
    	    $q->set( 'post__in', (array) $product_ids_on_sale );
        }
    
    	if(strstr($uri, 'new=1')) {
    		$q->set('date_query', array(
    			array(
    
    				'after' => "15 day ago"
    			)
    		));
    	}
    }
    
    add_action( 'woocommerce_product_query', 'cjwc_product_query' );

    So basically when the request url has sale or new in it I override the default woocommerce query and only look for products_on_sale or products from the last 15 days.

    The categories widget is a little more complicated. I wrote my own widget and overwrote the Categories_Walker. My widget has an option to append a suffix to the url. I’ve created 3 widgets – one for the normal products, one for new and one for sales.

    new appends new=1 and sale appends sale=1 to the category urls.

    This way I’m always reusing the shop page, but returning the filtered results.

    At first I was using add_filter(‘term_link’, …) but this doesn’t work for me as I’m loading all the categories in a submenu. (all categories for new, for sale and for all products) And those categories needed to have all different suffixes. So it was necessary to write my own widget.

    I still have to modify other widget such as price, color etc to also append the suffix, but yea…

    If anyone has a better idea, please let me know!

    Hello! Did you somehow manage to implement this?

    Method – step-by-step:

    1. In the WordPress backend dashboard – Go to: → Appearance → Menus;
    2. If you don’t want a page showing all the products – Remove ?Shop? from Menu;
    3. To add shop pages that will only show products in specific categories – At the top of your Menus window, click on ?Screen Options?;
    4. Add a checkmark on ?Product Categories?;
    Now you can simply add the ?Product Categories? to your menu;

    I used this plugin to achieve this,
    https://www.ads-software.com/support/plugin/hide-categories-or-products-on-shop-page/

    also, the plugin developer demonstrates how to achieve the result, unfortunately, it’s not working for me.

    @lorro Thanks for sharing, it has worked for me

    @modocodo
    Please ask your question in a new topic. I’ve removed your reply to this old thread (and I’m also closing this thread now).
    Also: There are literally tens of thousands of volunteers helping other WordPress users in these forums. Avoid mentioning one of them just to ask your question. People who are willing to help are looking for (new) topics where they can contribute.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Create multiple shop pages’ is closed to new replies.