With WooCommerce, I have faced a problem on my code below: I have tried skip specific category from my loop. Product has been skipped but some remaining products are showing multiple times:
foreach ( $order->get_items() as $item_id => $item ) {
$product_id = $item->get_product_id();
$terms = get_the_terms( $product_id, 'product_cat' );
foreach ($terms as $term) {
if ($product_cat_id != 38355) { //category id
echo $name = $item->get_name().'<br>';
}
}
}
How can I avoid this item name repetition on this loop?