Get a list of Product Categories inside a loop

I am trying to list out product categories as a list

Farm Cycle: 6 Months
KADUNA

The code below output as
Farm Cycle: 6 Months, KADUNA

add_action( ‘wpo_wcpdf_after_item_meta’, ‘wpo_wcpdf_show_product_categories’, 10, 3 );
function wpo_wcpdf_show_product_categories ( $template_type, $item, $order ) {
// get a comma separated list of categories (category links stripped)
if (isset($item[‘product’])) {

echo ‘<div class=”product-categories”>DETAILS:<br/> ‘.strip_tags( wc_get_product_category_list( $item[‘product’]->get_id() ) ).'</div>’;
}
}

Read more here:: Get a list of Product Categories inside a loop

Leave a Reply

Your email address will not be published. Required fields are marked *