2016-03-06 29 views
0

提供給我的模板的以下部分試圖輸出產品屬性(名稱,例如'電壓'值'240V'),但是所有輸出的都是例如'pa_voltage 「沒有價值產品詳細信息的Woocommerce打印 - 包括所有可見的屬性

<?php 
    $attributes = $product->get_attributes(); 
    if (count($attributes) > 0) { 
     ?> 
     <table class="attributes"> 
      <?php 
      foreach ($attributes as $att) { 
       if ($att['is_visible']) { 
        ?> 
        <tr> 
         <td><span><?php echo $att['name'] ?></span></td> 
         <td><span><?php echo $att['value'] ?></span></td> 
        </tr> 
        <?php 
       } 
      } 
      ?> 
     </table> 

     <?php 
    } 
    ? 

回答

0

其實你得到只是屬性,但你在這裏所需要的屬性的變化是這樣的:!?!。

$all_attr = $product->get_available_variations(); 
if (count($all_attr) > 0) { 
    foreach ($all_attr as $attr) { 

     foreach ($attr['attributes'] as $key => $value) { 
      echo $key."<br>"; 
      echo $value; 
     } 
    } 
} 
+0

輝煌乾杯瑪哈這給了我,我需要的方向....謝謝,PM。 – Peter

相關問題