Depending on the product category, I have different data to display on category page. I'm getting my category ID
this way:
<?php global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term) {
$product_cat_id = $term->term_id;
break;
}
if ($product_cat_id == "6") {
echo "aaa";
}
elseif ($product_cat_id == "7") {
echo "bbb";
}
?>
But I need to display different data when product is in two categories and it does not work.
echo $product_cat_id;
It recognizes only one category. How do I make it recognize two and make IF
statement for product which is in category 6 AND
7?