• Resolved hemp1111

    (@hemp1111)


    Hello guys, I have an issue with Woo which I don’t know how to solve, on my main product page I put a woo shortcode and it displays my categories separated from the product which is great. But it also displays my subcategories on the main product page which I don’t want. I want only categories separated from the products on the main shop page. Also when I click on that subcategory it showing me subcategories and products all together but I want it to be separated from one another. Please guys, if anyone has a good will to help me out it’ll make my day.

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Support Grigorij S. a11n

    (@grigaswp)

    Hi there,

    Thanks for reaching out!

    I have an issue with Woo which I don’t know how to solve, on my main product page I put a woo shortcode and it displays my categories separated from the product which is great. But it also displays my subcategories on the main product page which I don’t want. I want only categories separated from the products on the main shop page.

    Is https://hemp-secret.com/hemp-products/ your shop page or not? What is the shortcode that you’re using? Also, is it the shortcode that adds subcategories or those appear without the shortcode too?

    Also when I click on that subcategory it showing me subcategories and products all together but I want it to be separated from one another. Please guys, if anyone has a good will to help me out it’ll make my day.

    With WooCommerce by default, it is possible to select whether your category pages display products, subcategories or both products and subcategories and this can be adjusted in Appearance >> Customize >> WooCommerce >> Product Catalog:

    https://cld.wthms.co/JiWdLD

    If you’d like to display both products and subcategories but have those separated – you’ll probably have to customize the code of the extension or hire a developer.

    Using a plugin such as Nested Category Layout might be an option even though it is not quite what you’re looking for

    Thread Starter hemp1111

    (@hemp1111)

    Hello, thanks a lot for your reply, the first issue is solved by this shortcode, [product_categories number=”0″ parent=”0″] I don’t know if I did a correct thing but now I only see my main categories in that hemp-products/ page.

    As for the second issue I have, is there any possibility to do that myself? I really want to learn all this stuff, because I’m building multiple websites, so if there’s any way to do it myself please let me know, if not, I have not choice but to hire someone. Thanks again for your reply. Cheers.

    Plugin Support Grigorij S. a11n

    (@grigaswp)

    Hi there,

    Hello, thanks a lot for your reply, the first issue is solved by this shortcode, [product_categories number=”0″ parent=”0″] I don’t know if I did a correct thing but now I only see my main categories in that hemp-products/ page.

    I’m glad to hear that you were able to modify the shortcode to display categories the way you need them to! parent=”0″ is the part that did the trick here, 0 means only show parent categories, 1 would make sub-categories of first level to appear and so on.

    As for the second issue I have, is there any possibility to do that myself? I really want to learn all this stuff, because I’m building multiple websites, so if there’s any way to do it myself please let me know, if not, I have not choice but to hire someone. Thanks again for your reply.

    Here are a few resources explaining the customization process I found with a quick Google search:

    https://code.tutsplus.com/tutorials/display-woocommerce-categories-subcategories-and-products-in-separate-lists–cms-25479

    Separate Products from Categories
    byu/Drunk_but_Functional inwoocommerce

    The functionality might be slightly different and some PHP knowledge would be necessary in order to implement that.

    Basically you’d have to override the single category page template file (I see woocommerce/includes/wc-template-functions.php suggested in one of the resources) by placing a copy of it to the folder of your child theme and modifying the code.

    If you decide to pursue such functionality and find yourself in need of help with the code – I can recommend reaching out to someone from customizations page on WooCommerce.com.

    I hope this helps!

    Thread Starter hemp1111

    (@hemp1111)

    Thank you very much for taking the time to answer my queries, definitely I’ll need to hire someone. One more question before I close up, I’ve found this code somewhere on the internet, any idea on how to try to implement this?

    https://gist.github.com/twoelevenjay/a2195b052c4feb046d7f71fcae5c4d1b

    • This reply was modified 5 years, 9 months ago by hemp1111.
    Plugin Support Grigorij S. a11n

    (@grigaswp)

    Hi there,

    Thank you very much for taking the time to answer my queries, definitely I’ll need to hire someone.

    Hiring an experienced developer will definitely save you a lot of time!

    One more question before I close up, I’ve found this code somewhere on the internet, any idea on how to try to implement this?

    https://gist.github.com/twoelevenjay/a2195b052c4feb046d7f71fcae5c4d1b

    It seems that a couple of new functions are introduced with this file, so these functions would probably have to be added to your functions.php file, although it would take someone proficient with WordPress and PHP to actually implement this.

    Thread Starter hemp1111

    (@hemp1111)

    One more thing, I’m using Oceanwp theme.

    Plugin Support Grigorij S. a11n

    (@grigaswp)

    Hi there,

    One more thing, I’m using Oceanwp theme.

    This shouldn’t make a difference, but it might be worth reaching out to the support team of OceanWP, maybe they will have an easier solution for you.

    Thread Starter hemp1111

    (@hemp1111)

    Thank you very much, I lost almost four days already searching for the solution. Have a wonderful day and thank you for your help. Cheers.

    Thread Starter hemp1111

    (@hemp1111)

    I want to tell you that I’ve found a solution with this code added in my function.php
    I thought it may be helpful for someone who have the issue like me.

    /**
    * Move WooCommerce subcategory list items into
    * their own <ul> separate from the product <ul>.
    */
    add_action( 'init', 'move_subcat_lis' );
    function move_subcat_lis() {
    	// Remove the subcat <li>s from the old location.
    	remove_filter( 'woocommerce_product_loop_start', 'woocommerce_maybe_show_product_subcategories' );
    	add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_start', 1 );
    	add_action( 'woocommerce_before_shop_loop', 'msc_maybe_show_product_subcategories', 2 );
    	add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_end', 3 );
    }
    /**
     * Conditonally start the product loop with a <ul> contaner if subcats exist.
     */
    function msc_product_loop_start() {
    	$subcategories = woocommerce_maybe_show_product_subcategories();
    	if ( $subcategories ) {
    		woocommerce_product_loop_start();
    	}
    }
    /**
     * Print the subcat <li>s in our new location.
     */
    function msc_maybe_show_product_subcategories() {
    	echo woocommerce_maybe_show_product_subcategories();
    }
    /**
     * Conditonally end the product loop with a </ul> if subcats exist.
     */
    function msc_product_loop_end() {
    	$subcategories = woocommerce_maybe_show_product_subcategories();
    	if ( $subcategories ) {
    		woocommerce_product_loop_end();
    	}
    }
    • This reply was modified 5 years, 9 months ago by hemp1111.
    • This reply was modified 5 years, 9 months ago by hemp1111.
    Plugin Support Grigorij S. a11n

    (@grigaswp)

    Hi there,

    Thank you for sharing the code here! It’s the same code from here https://gist.github.com/twoelevenjay/a2195b052c4feb046d7f71fcae5c4d1b right?

    In that case it might be best to keep it as a link as the code may be updated when necessary on GitHub but it won’t be updated when pasted here.

    Also, it’s a good idea to only add the code to your child theme’s functions.php file so that theme updates don’t wipe the code out.

    Anyway, I’m glad to hear that you were able to achieve the functionality you were looking for.

    Have a lovely day/night! ??

    Thread Starter hemp1111

    (@hemp1111)

    Yes, that’s the link you’ve just shared, but I’ve only changed

    add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_start', 40 );
    	add_action( 'woocommerce_before_shop_loop', '
    msc_maybe_show_product_subcategories', 50 );
    	add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_end', 60 );

    to

    add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_start', 1 );
    	add_action( 'woocommerce_before_shop_loop', 'msc_maybe_show_product_subcategories', 2 );
    	add_action( 'woocommerce_before_shop_loop', 'msc_product_loop_end', 3 );

    that can be also found in the comment of that post on GitHub. Now I’m creating a child theme and I’ll copy a function.php file in it.

    Thank you for your help actually you helped me a lot.

    @hemp1111 Thank you!!!! I almost gave up.

    Shame on you WooCommerce!! You should have built this LOGICAL functionality in years ago, this is shoddy coding on your part! This behavior is expected in all shopping carts, not an extravagant luxury – it’s logical to separate them. By the way, it’s been a suggestion on your list for several years now. When are you going to add this in?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Subcategories are showing with the categories and products.’ is closed to new replies.