I made the below for my sidebar to show the subcategories of a specific category (ID 89) of my choosing. Only the subcategories that the post is in appear. Works great.
Now I want to change my posts in to WooCommerce Products, so I'm trying to adapt the code to target WC subcategories instead of post categories. I'm a bit lost on where to start.
<ul>
<?php foreach (get_the_category() as $childcat) : ?>
<?php if (cat_is_ancestor_of(89, $childcat)) { ?>
<li>
<a href="<?php echo get_category_link($childcat->term_id); ?>"><?php echo $childcat->cat_name; ?></a>
</li>
<?php } ?>
<?php endforeach; ?>
</ul>