我用下面的函數調用來獲取產品的變化,如何從woocommerce中的變體ID中檢索變體名稱?
$available_variations = $product->get_available_variations();
而在返回$ available_variations我所有的變化。
我得到了variation_id,而且我不知道該屬性的名稱,在本例中屬於原產國,那麼如何檢索屬性值,即香港和新加坡在這種情況下?
下面是高於$ available_variations的轉儲,
[18-Mar-2014 17:04:20 UTC] Array
(
[variation_id] => 2968
[attributes] => Array
(
[attribute_pa_country-of-origin] => hong-kong
)
[image_src] =>
[image_link] =>
[image_title] =>
[image_alt] =>
[price_html] => <span class="price"><span class="amount">SGD$15</span></span>
[availability_html] =>
[sku] =>
[weight] => kg
[dimensions] =>
[min_qty] => 1
[max_qty] => 0
[backorders_allowed] =>
[is_in_stock] => 1
[is_downloadable] =>
[is_virtual] =>
[is_sold_individually] => no
)
[18-Mar-2014 17:04:20 UTC] Array
(
[variation_id] => 2969
[attributes] => Array
(
[attribute_pa_country-of-origin] => singapore
)
[image_src] =>
[image_link] =>
[image_title] =>
[image_alt] =>
[price_html] => <span class="price"><span class="amount">SGD$12</span></span>
[availability_html] =>
[sku] =>
[weight] => kg
[dimensions] =>
[min_qty] => 1
[max_qty] => 0
[backorders_allowed] =>
[is_in_stock] => 1
[is_downloadable] =>
[is_virtual] =>
[is_sold_individually] => no
)
這不是海報問的問題,他希望從變體ID中獲取變體的名稱 – Roy