WooCommerce Categories Looper Shows Parent + Sub-Categories

When we use the Woo Product Categories looper provider on a Shop page we’ve laid out in Cornerstone, it displays both categories and sub-categories, unlike the default Shop page. How do we get it to ONLY display the parent categories?

I’ve already tried to change the looper to “Current Post Terms” but that only shows a single random category on the page. What is the proper way to do this?

Hello @co50,

Thanks for writing in! Please be advised that both the Looper Provider All Terms and Looper Provider Current Terms will display the parent and sub terms. You will have to use custom PHP code that will return only the parent terms and use the Looper Provider Custom. Perhaps this thread can help you:

Best Regards.

Wow, that’s lame. This should be built into Cornerstone and not require custom coding. At the very least, you should have a snippet on hand to aid with what seems to be a glaring hole in the custom shop page experience.

@charlie - do you agree that there should be established guides for this as it’s likely something MANY Cornerstone users wish to do with WooCommerce? Specifically:

  1. When using a custom shop page, which is the proper looper setup to show categories as they are shown on the default Shop page (i.e. Parent categories only and not every parent/sub in the entire store)

  2. When using a custom category browsing page (i.e. the page you go to when selecting a parent category on the Shop page), what is the proper looper setup so that a) sub-categories for the parent category you clicked on, if they exist, are shown properly as they do with the default Woo pages, b) images for those sub-categories are shown properly.

This stuff should not require custom PHP coding. And if it does require custom coding, Themeco should provide that coding in lieu of not having this much-needed feature in place already. Thank you.

Hey @co50,

Your issue has been in the pipeline added in our enhancement lists. We do not have an ETA yet on which update release the feature will be available. For the time being, you can use the Looper Provider Custom along with the custom PHP.

Please bear with us.

OK, but I’m still looking for an answer to my question…specifically #2. In lieu of Cornerstone not supporting this out of the box, which it certainly should, what is the workaround? I could not find this in any existing forum posts.

Thank you for the update.

For number 2, you can try @ruenel’s suggestion in the following thread: Display product categories (WooCommerce) in a structured way (Parent / Child)

You will have to add the “cs_looper_custom_subcat” filter to the functions.php file, make sure the Looper Provider > Hook field is set to “subcat” and in the looper parameters, add the “parent_cat” entry with the value “{{dc:term:id}}” as shown in the screenshots in the previous thread.

Let us know if you need further assistance.

I’ve already tried following that thread, and did as you instructed and this does not work. Again, I’m baffled that there is no guide on how to do this with clear instructions. What I’m asking for is very simple:

The user starts here on /shop/. Parent categories show properly using the built-in looper functions. Why does it show the same image for every category and not the actual category’s image? I have no idea. Was going to address that in a separate thread. But at least the categories show here…

If they click a parent category with sub-categories, they get this useless page, which inexplicably is paginated despite nothing being on page 1. Subsequent pages show products from the category. What this page should show is sub-categories of the parent category. That’s it. But it doesn’t. I’ve tried all the tricks in the thread you pointed to. It doesn’t work (though me and the OP of that thread are trying to accomplish different things). How do we make this happen?

Again, this is standard Woo functionality. You’re getting asked this a lot. Wouldn’t it be more efficient to just write up a guide ONCE and then not have to keep answering support inquiries about this? Custom WooCommerce archives pages are useless to anyone using sub-categories out of the box.

So I ask, could you explain in non-developer terms how to make this happen?

Hello @co50,

What dynamic content did you use for the category image? It should be using the term meta dynamic content. We would love to check your layout so we can inspect and be able to help you with your issue. You can create a secure note in your next reply with the following info:
– Link to your site
– WP login URL
– WP username
– WP password
– WP Administrator Role
– Confirmation that we can access and make changes to your site

To know how to create a secure note, please check this out: How The Forum Works

image

Best Regards.

I don’t know what you’re saying here. “Term meta dynamic content”. What does that even mean?

I’m happy to do this myself but the unending half-explanations and partial instructions aren’t useful. I’ve saved a Secure Note.

Hello @co50,

Most of your product categories do not have category images.

You may use {{dc:term:meta key="product_cat_thumbnail"}} dynamic content to display the product category image.

By the way, the given user credentials has very limited privileges. We do not have any access to any of the Cornerstone layouts. We were not able to check your layouts.

Best Regards.

I’ve removed the limits. Sorry, that’s a default.

I had already tried that dynamic content tag but it doesn’t show the category images.

Thank you for the update and for your patience.

We duplicated the WooCommerce Browse Items template and named it WooCommerce Browse Items B for lack of imagination. This template relies on the Code Snippet > Output only Subcats for Woo Browse Pages or the cs_looper_custom_subcat filter, which retrieves the subcategories of the current parent category. This is only applied to the Accessories category for now and it seems to be working as expected. The only issue is that in the Settings > Assignments > Conditions , you’ll have to manually select all parent Product Categories. If not, this same template will be applied to the child categories, and it won’t be possible to access the items inside those categories.

We have included the links to the template and the category page in the secure note.

Let us know if this is acceptable.