[英]show Woocommerce checkout page depending on product category
我有一個問題,需要在結賬插件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>
謝謝
使用 trim() 函數去除空格。 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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.