Get Third Level Categories WooCommerce

Question

I am trying to get third Level WooCommerce categories. Here follows my source code:

$args = array(
    'hierarchical' => 1,
    'show_option_none' => '',
    'hide_empty' => 0,
    'parent' =>18,
    'taxonomy' => 'product_cat'
);
$subcats = get_categories($args);
echo '<div class="wooc_sclist">';
foreach ($subcats as $sc) {
    $link = get_term_link($sc->slug, $sc->taxonomy);
    echo '<ul><a href="' . $link . '">' . $sc->name . '</a>';
$args2 = get_term(array(
            'hierarchical' => 0,
            'hide_empty' => false,
           // 'taxonomy' => 'product_cat'
        ));
        $subsubCats = get_categories($agrs2);
        foreach ($subsubCats as $subsubCats) {
            $SubLinks = get_term_link($subsubCats->slug, $subsubCats-
   >taxonomy);
            echo '<li>sub -<a href=' . $SubLinks . '>' . $subsubCats->name .'</a></li>';
        }
echo '</ul>';
}
echo '</div>';
wp_reset_query();
0
Ammad Nazir 2 years 2020-01-07T08:41:05-05:00 0 Answers 84 views 0

Leave an answer

Browse
Browse