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 ?
Thanks!
Use
get_the_terms
Is better to use
wc_get_post_terms()
from a product ID (that allows to get term names instead of WP_Term Objects) and depending on what plugin you are using, the taxonomy will be different:product_brand
for Woocommerce Brands pluginyith_product_brand
for YITH WooCommerce Brands pluginpa_brand
for a custom product attributeSo for example with Woocommerce Brands plugin you will use:
Related:
Thanks for the help , I used this code and it works.