Add Product categories on invoices under product name

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'])) {
if (function_exists('wc_get_product_category_list')) {
// WC3.0+
$category_list = wc_get_product_category_list( $item['product']->get_id() );
} else {
$category_list = $item['product']->get_categories();
}
echo '

Categories: '.strip_tags( $category_list ).'

';
}
}

if categories does not show… replace the $item[‘product’]->get_id() to $item[‘product_id’].

Leave a Reply