WooCommerce : bug / feature request / documentation

Sorry to post this here but I’m having no luck with support so not really sure if I am being stupid or if there is a bug or if we require an additional feature.

The basics are that I have set the Woo settings in Appearance -> Customize -> WooCommerce -> Product Catalog to do the following:

  • Shop page = Show categories
  • Category page = Show subcategories

I have used a Woo Archive in the layout builder and set that display for the shop.

The issue I have is that the archive doesn’t seem to use the loop based on the shop settings so no matter what I try I cannot get my shop page to show only the top level categories.

I can get it to show all shop categories and I can hide the empty ones as those settings are self-explanatory but no matter what I do I can’t just show the main top level categories.

Perhaps I am missing something, perhaps it is a bug or perhaps it is not built like that. I really don’t know.

To follow on from this it would be great if you could either do some videos or just some documentation on building the basic default woo layouts (honestly I prefer documentation). We don’t need anything fancy but some basic how to’s of putting the basic pages together so that we can take advantage of the speed of the builder rather than needing to custom code shop layouts.

So just to follow up here support seems to think the only way to do this is using the custom hook option.

This seems like an over-site to me.

One would expect an archive page to contain the WordPress loop based on the settings in Appearance -> Customize -> WooCommerce specifically for shop and category pages.

Hi @urchindesign,

This seems like an over-site to me.

It’s possible - I don’t recall testing that use case, so what might be happening is Pro inserts the Layout before WooCommerce has an opportunity to modify the query, so it doesn’t get those settings changed. I can’t look into this in depth at the moment but that could be why you’re seeing this behavior.

Post Theme Options reboot we’ll likely be revisiting all things WooCommerce and eventually even having some demo content that fully sets up a shop for you powered by Layouts. Until the, regretfully there might be more need for special customization to get things working in specific ways.

Thanks. I’ve kind of figured out a custom looper for this. The problem I seem to be having now is that my function works if I hard code a value but if I pull the value from the arg then my array doesn’t work.

I’ve tried passing the {{dc:term:slug}}, {{dc:term:id}} and the {{dc:term:name}} all with the same result.

So my custom loop is passing a key prod_cat to my custom function.

This is not the complete function and it still needs some cleaning up and validation but here it is:

add_filter(‘cs_looper_custom_subcat’, function($result, $args) {
$prodcatslug = $args[‘prod_cat’];
$productidArray = get_term_by( ‘slug’, $prodcatslug, ‘product_cat’ );

var_dump($productidArray);

}, 10, 2);

So basically with the above the var_dump returns as bool(false). But if I take $prodcatslug and hard code the same value that I pass through the looper then var_dump returns the expected array.

If I echo $prodcatslug either with the hard coded value or the value pulled from the $args it echos the same thing.

Hopefully that makes sense.

Hey @alexander,

Also having the same issue as @urchindesign here, when putting variables into the params field it doesn’t seem to be pushing the results to the custom looper. Is this something that is doable with params?

I’m using a custom looper I found on the forum which pushes on the sub categories of a parent id and im hoping to make the params be dynamic pushing in the current archive id, instead of having to make a layout for each category which seems a bit backwards.

Just for context here is the custom looper:

add_filter('cs_looper_custom_subcat', function($result, $args)
    {
    $parent_cat=$args['parent_cat'];
    $cat_args=get_categories(
    array( 
    	'child_of'=> $parent_cat,
    	'taxonomy'=> 'product_cat',
    	'hide_empty'=> 0,
    )
    );

    $subcats = $cat_args;
    return $subcats;
    }, 10, 2);

and this is the params I’m hoping to push through:
{ "parent_cat":"{{dc:archive:id}}" }

Hi @Maratopia_Digital and @urchindesign,

Presently, the JSON code editors don’t support inserting dynamic content into them, so it isn’t going to resolve {{dc:archive:id}} to the actual ID. It’s possible to get the current Term by doing this:

$term = CS()->component('Dynamic_Content')->get_contextual_term();
$parent_cat = $term->id;

That being said, this isn’t an official API and it’s likely to break with a future update. The CS()->component() method is from the days when we had to be PHP 5.2 compatible and we’re most likely going to change that a bit with the Theme Options reboot release.

Meanwhile, I’ve got some notes on adding dynamic content support to the Custom Looper Provider Params and the JSON Looper Provider code editors.