What I trying to do is showing brand name under product title in cart page, for testing I didn't use function in function.php, and did direct change to cart.php but no success:
$product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );
$brands = wp_get_post_terms( $product_id, 'pwb-brand' );
foreach( $brands as $brand ) echo '<p>'.$brand->name.'</p>';
but nothing shows, I used var_dump($brands) in return:
object(WP_Error)#37768 (3) { ["errors"]=> array(1) { ["invalid_taxonomy"]=> array(1) { [0]=> string(22) "Invalid category" } } ["error_data"]=> array(0) { } ["additional_data":protected]=> array(0) { } }
I also tried other ways:
wp_get_post_terms($product_id, 'product_brand', ['fields' => 'names'])
return nothing and same error. What I have done wrong?