2017-12-26 3 views
0

私は、選択したカテゴリの製品価格の後に "1平方フィート"を追加するwoocommerce用のコードがあります。私は「1平方フィートあたり」にも同様に適用したい別のカテゴリを追加しました。私は成功しなかった配列を追加する必要があると思う。ここでは単一のカテゴリ価格の後にメッセージを複数のカテゴリに追加

add_filter('woocommerce_get_price_html', 'custom_price_message'); 
 
    
 
function custom_price_message($price) { 
 
    
 
if (!has_term('stone', 'product_cat')) { 
 
    return $price; 
 
    
 
} elseif (!empty($price)){ 
 
    $vat = ' per ft<sup>2</sup>'; 
 
    return $price . $vat; 
 
    
 
}else{ 
 
    return 'Call for Price'; 
 
} 
 
}

+0

基本的に、私は「用語を持っている場合は、」機能を作る方法を知っておく必要があり、複数の製品カテゴリに適用されます。 –

答えて

0

ないここでは初めてしかし、私は間違って何をしたか確実に動作しますが、私は考え出した、それは私が持っているものです。ここに私が使った配列があります。

add_filter('woocommerce_get_price_html', 'custom_price_message'); 
 
    
 
function custom_price_message($price) { 
 
    
 
// Set HERE your product categories in the array 
 
$categories = array('stone', 'remnants'); 
 
    
 
if(!has_term($categories, 'product_cat')){ 
 
    return $price; 
 
    
 
} elseif (!empty($price)){ 
 
    $vat = ' per ft<sup>2</sup>'; 
 
    return $price . $vat; 
 
    
 
}else{ 
 
    return 'Call for Price'; 
 
} 
 
} 
 

関連する問題