【发布时间】:2016-12-22 00:49:49
【问题描述】:
我想在单个产品页面中列出我的产品变体及其尺寸,尺寸部分一切正常,但我无法显示变体名称。这是我的代码:
<?php
$variations = $product->get_available_variations();
foreach ( $variations as $variable_array ){
$variation = new WC_Product( $variable_array['variation_id'] );?>
<tr>
<td>
<b>here I need the variation title</b>
</td>
<?php
$magassag = $variation->height;
?>
<?php if ($magassag != 0) {
echo '<td class="cell_magas">' . $variation->height . ' cm' . '</td>'; }
else{
?>
<style type="text/css">#magassag-cim{display:none;}</style>
<?php } ?>
<?php
$atmero = $variation->width;
?>
<?php if ($atmero != 0) {
echo '<td class="cell_szell">' . $variation->width . ' cm' . '</td>'; }
else{
?>
<style type="text/css">#szellesseg-cim{display:none;}</style>
<?php } ?>
<?php
$szellesseg = $variation->length;
?>
<?php if ($szellesseg != 0) {
echo '<td class="cell_latime">' . $variation->length . ' cm' . '</td>'; }
else{
?>
<style type="text/css">#szellesseg-cim{display:none;}</style>
<?php } ?>
<td>
<?php echo $variation->price;?>
</td>
</tr>
【问题讨论】:
标签: php wordpress woocommerce product variations