global $product;
$product_id = get_the_ID();
$product_cat = get_the_terms( $product_id, 'product_cat' );
echo esc_html(implode(', ', wp_list_pluck($product_cat, 'name')));
// OR
$last_cat = count($product_cat) - 1;
foreach ($product_cat as $key => $cat) {
printf(
'<span class="product-category"><a href="%s">%s</a></span>',
esc_url(get_category_link($cat->term_id)),
esc_html($cat->name) . ($key !== $last_cat ? ', ' : '')
);
}
// OR
<span><?php echo _n( 'Category:', 'Categories:', count( $product->get_category_ids() ), 'woocommerce' ); ?></span>
<p class="product-details-category">
<?php
echo wc_get_product_category_list(
$product->get_id(),
', '
);
?>
</p>
<span><?php echo _n( 'Tag:', 'Tags:', count( $product->get_tag_ids() ), 'woocommerce' ); ?> </span>
<?php
echo wc_get_product_tag_list(
$product->get_id(),
', ',
'<p class="tagged_as">',
'</p>'
);
?>
<span><?php esc_html_e( 'SKU:', 'woocommerce' ); ?> </span>
<p class="sku_wrapper">
<span class="sku"><?php echo ( $sku = $product->get_sku() ) ? $sku : esc_html__( 'N/A', 'woocommerce' ); ?></span>
</p>