How to get category name from the product id in woocommerce.
// Get the product id from the order id -
<?php
$order = new WC_Order( $order->id );
$items = $order->get_items();
foreach ( $items as $itemty ) {
$product_id = $itemty['product_id'];
}
// then from product id get the category name
$cat_id=get_the_terms( $product_id, 'product_cat' );
foreach ( $cat_id as $ite ) {
echo $cat = $ite->name."<br>";
}
?>