我想添加我在产品属性中定义的产品品牌和重量,但它使用
<?php
$weightvalues = get_the_terms( $product->id, \'pa_weight\');
foreach ( $weightvalues as $weightvalue ) {
echo $weightvalue->name;
} ?>
我在产品页面中使用了它,但它在下面的代码中不起作用。我该怎么办?
<?php
$title=\'\';
if($show_title)
{
//$title = \'<h3 class="ls-result-title"><a href="\'.$product->get_permalink().\'">\'.$product->get_title().\'</a></h3>\';
$variation_label=\'\';
if(get_post_type($pid)==\'product_variation\'){
$all_meta = get_post_meta( $pid );
foreach ( $all_meta as $name => $value ) {
if ( ! strstr( $name, \'attribute_\' ) ) {
continue;
}
if($value[0]!=\'\')
$variation_label.=\' - \'.str_replace(array("pa_","attribute_"),"",$name).\' : \'.$value[0];
}
}
$title = \'<h3 class="ls-result-title"><span class="brand"></span><a href="\'.$product->get_permalink().\'">\'.$product->get_title().$variation_label .$terms.\' </a></h3><h4></h4>\';
}
?>