Search code examples
phpwordpresswoocommercecustom-taxonomytaxonomy-terms

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!


Solution

  • Use get_the_terms

    get_the_terms($product->get_id(),'pa_brand')