显示Woocommerce结账页面根据产品类别
问题描述:
我有一个问题,需要显示在结账插件WooCommerce类别,用下面的代码显示Woocommerce结账页面根据产品类别
<td class="product-cat" >
<?php
$terms = get_the_terms($product_id, 'product_cat');
foreach ($terms as $term) {
$product_cat = $term->name;
}
echo $product_cat ;
?>
</td>
抛出了我勇气成就展示,但我用空格甩,我需要这个值来验证另一个领域,我的意思是,如果category = 1,jQuery的显示另一个输入,如果没有隐藏
,但给我的价值空间,我不能让它工作,我验证
副产品代码
<td class="product-cat">
Video Clases </td>
由于
答
使用修剪()函数来剥离空格。 http://php.net/manual/en/function.trim.php
试试这个:
<td class="product-cat" ><?php
$terms = get_the_terms($product_id, 'product_cat');
foreach ($terms as $term) {
$product_cat = $term->name;
}
echo trim($product_cat) ;
?></td>
试试你的代码,但我还是用空格显示。 尝试将修剪放在变量$ terms中,但页面下降,另一个可能的解决方案? 感谢您的回答mertizci – Amaroak