Site icon Hip-Hop Website Design and Development

The way to get associated class/classes in WordPress archive web page

I’m utilizing WooCommerce in WordPress. I’ve few classes of merchandise like these,

Instance:

Product 1 Class (//dad or mum)
-- Class 1
-- Class 2
-- Class 3
-- Class 4
Product 2 Class (//dad or mum)
-- Class 10
-- Class 11
-- Class 12
-- Class 13

If I’m in a archive web page for Class 2(sub) How can I get all different class title below the dad or mum class (Product 1 Class) as an inventory.

what i am making an attempt

$args = array(
       'hierarchical' => 1,
       'show_option_none' => '',
       'hide_empty' => 0,
       'dad or mum' => $parent_cat_ID,
       'taxonomy' => 'product_cat'
   );
$subcats = get_categories($args);
echo '<ul class="wooc_sclist">';
foreach ($subcats as $sc) {
       $hyperlink = get_term_link( $sc->slug, $sc->taxonomy );
echo '<li><a href="'. $hyperlink .'">'.$sc->title.'</a></li>';
     }
echo '</ul>';
}

Out put ought to :

.Class 1
.Class 2
.Class 3
.Class 4

I’ve use under code which works nice in single-product.php web page –

<?php 
 $dad or mum = get_category_parents( $cat, true, ' &raquo; ' ); 
echo $product->get_categories( ', ', '<span>' . _n( 'Class:', 'Classes:', sizeof( get_the_terms( $post->ID, 'product_cat' ) ), 'woocommerce' ) . ' ', '.</span>' ); 
?>