Answer the question
In order to leave comments, you need to log in
How to display product category id in woocommerce loop?
there is a code:
<?php global $woocommerce;
$items = $woocommerce->cart->get_cart();
foreach($items as $item => $values) {
$_product = wc_get_product( $values['data']->get_id());
echo wc_get_product_category_list( $values['data']->get_id());
}?>
Answer the question
In order to leave comments, you need to log in
Displays the id of the product category
$product_cats_ids = wc_get_product_term_ids($values['product_id'], 'product_cat');
echo $product_cats_ids[0];
$terms = get_the_terms($values['product_id'], 'product_cat');
echo $terms[0]->slug;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question