我有这个代码,它显示了最好的销售,但它也显示了没有库存的产品,我如何修改代码。这样它只显示有库存的产品吗?。谢谢 !
$best_sellers_args = array(
'post_type' => 'product',
'meta_key' => 'total_sales',
'posts_per_page' => 6,
'orderby' =>'meta_value_num',
'order' => 'DESC'
);
$products = new WP_Query( $best_sellers_args );
Run Code Online (Sandbox Code Playgroud) 我需要产品的品牌名称,我有这个代码
$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(); ---> ???
Run Code Online (Sandbox Code Playgroud)
我得到了这个属性,但我不知道如何抓住品牌名称,还有其他方法吗?
谢谢!