Display Woocommerce Product Category on cart and checkout page

Solution:

the woocommerce>templates>cart>cart.php is the cart page.In this,foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) loop display the products you added to the cart.Variable $product_id of the loop have the id of each product you added the the cart. Put this code inside the loop

$terms = get_the_terms( $product_id, 'product_cat' );
foreach ($terms as $term) {
   $product_cat = $term->name;
}
echo $product_cat ;

It will display the categories. Work out and let me know:)