I am trying to list out product categories as a list
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>';
}
}
I am trying to list out product categories as a list
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>';
}
}
Share
Improve this question
asked Jun 12, 2019 at 12:38
Odutola AbisoyeOdutola Abisoye
31 bronze badge
0
1 Answer
Reset to default 0Please try this code this will give you categories in list format:
echo '<ul>' . wc_get_product_category_list( $item['product']->get_id(), '</li><li>', '<li>', '</li>' ) . '</ul>';