2014-11-06 126 views
0

在購物車中,我獲取了我所有可變產品的變體ID。Woocommerce:從購物車中的物品中獲取所選屬性

是否有可能以任何方式從該ID中選擇屬性?

我曾嘗試:

<?php $variation = new WC_Product_Variation($cart_item[variation_id]);?> 

<?php foreach($variation->get_variation_attributes() as $name => $attr): ?> 
    <?php $name = substr($name, 10); //remove attribute_ from the key. ?> 

    <?php echo $variation->get_attribute($name); ?> 

<?php endforeach; ?> 

,但只輸出所有可用屬性的變異,而不是選擇之一。

感覺就像我在這裏丟失了一些明顯的東西,所以任何正確的方向上的指示都會很可愛。

回答

相關問題