add_filter( 'woocommerce_get_price_html', 'wb_change_product_html' );
function wb_change_product_html( $price ) {
$cat_arr = get_the_terms(get_the_ID(),'product_cat');
//return $a[0]->name;
$temp = 0;
foreach ($cat_arr as $singl_cat) {
//тут вбиваем вместо per_unit вашу категорию
if($singl_cat->name == 'per_unit') {
$temp = 1;
}
}
if ( $temp ) {
$price_html = '<span class="amount">' . 'кг ' . $price . '</span>';
} else {
$price_html = '<span class="amount">' . 'единица ' . $price . '</span>';
}
return $price_html;
}
add_filter( 'woocommerce_cart_item_price', 'wb_change_product_price_cart' );
function wb_change_product_price_cart( $price ) {
if ( is_product_category( 'kg' ) ) {
$price_html = '<span class="amount">' . $price . ' кг' . '</span>';
} else {
$price_html = '<span class="amount">' . $price . ' " единица' . '</span>';
}
return $price_html;
}