Skip to content
Advertisement

How to get the brand name of product in WooCommerce

i need get the brand name of product , i have this code

$product = wc_get_product();

  $type = $product->get_type();      
  $name = (string)$product->get_name();
  $id = (int)$product->get_id(); 
  $sku  = (int)$product->get_sku(); 
  $precio = (int)$product->get_price();

$brand_name = $product->get_brand(); ---> ???

i get this attributes but i don’t know how catch the brand name, is there another way ?

enter image description here

Thanks!

Advertisement

Answer

Use get_the_terms

get_the_terms($product->get_id(),'pa_brand') 
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement