如何在WooCommerce中获得产品的品牌名称 [英] How to get the brand name of product in WooCommerce

查看:245
本文介绍了如何在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 ?

谢谢!

推荐答案

使用get_the_terms

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

这篇关于如何在WooCommerce中获得产品的品牌名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆