我添加了-child / single-product / meta.php尺寸。如果我有单一产品,它可以工作-single product,但是如果我有变型产品,则什么也没显示-variation product
<?php
$dimensions = $product->get_dimensions();
if ( ! empty( $dimensions ) ) {
echo '<div class="dimensions">Rozměry: š.' . $product->get_width();
echo ' h.' . $product->get_length();
echo ' v.' . $product->get_height() . " " . get_option( 'woocommerce_dimension_unit' );
echo '</div>';
}
?>
答案 0 :(得分:0)
希望他能帮助您
global $product;
$variations = $product->get_available_variations();
foreach ( $variations as $variable_array ){
echo "<br>The length is. ".$variable_array['dimensions']['length'];
}