get_id(), '_custom_stock_status', true);
if ($custom_status) {
$status_text = '';
switch ($custom_status) {
case 'in_stock':
$status_text = 'В наличии';
break;
case 'low_stock':
$status_text = 'Осталось мало';
break;
case 'on_order':
$status_text = 'Под заказ';
break;
}
if ($status_text) : ?>
name );
$class = $is_discount ? 'product_page-discount' : 'product_page-popular';
echo '
' . esc_html( $tag->name ) . '
';
}
?>
get_sku();
if ($sku) : ?>
is_type( 'simple' );
if ( $show_specs ) {
/** ===== Длина */
$len_mm_meta = get_post_meta( $product->get_id(), '_variation_length', true );
if ( $len_mm_meta !== '' ) {
$len_mm_num = floatval( str_replace( ',', '.', preg_replace( '/\x{00A0}|\s/u', '', (string) $len_mm_meta ) ) );
$length_label = $len_mm_num > 0 ? number_format_i18n( $len_mm_num, 0 ) . ' мм' : '';
} else {
$len_sys = $product->get_length();
if ( $len_sys !== '' ) {
$unit = get_option( 'woocommerce_dimension_unit', 'cm' ); // 'mm','cm','m','in','yd'
$length_label = wc_format_localized_decimal( $len_sys ) . ' ' . $unit;
} else {
$length_label = '';
}
}
/** ===== Вес (3 знака, точка, всегда "кг") */
$weight_raw = $product->get_weight();
if ( $weight_raw !== '' ) {
$weight_num = (float) wc_format_decimal( $weight_raw );
$weight = number_format( $weight_num, 3, '.', '' ) . ' кг';
} else {
$weight = '';
}
/** ===== Атрибуты */
$attrs = $product->get_attributes();
// Собираем приоритетный диаметр и остаток
$diam_vn_html = ''; // diametr-vnesnij-vnutrennij
$diam_fallback = ''; // diametr (если нет основного)
$remaining_rows = [];
if ( ! empty( $attrs ) ) {
foreach ( $attrs as $attr ) {
if ( method_exists( $attr, 'get_visible' ) && ! $attr->get_visible() ) {
continue;
}
$raw_name = $attr->get_name();
$slug = $attr->is_taxonomy()
? wc_sanitize_taxonomy_name( str_replace( 'pa_', '', $raw_name ) )
: wc_sanitize_taxonomy_name( $raw_name );
// Пропускаем вес (ves) полностью — он выводится отдельно
if ( $slug === 'ves' ) {
continue;
}
// Получаем значение и метку
if ( $attr->is_taxonomy() ) {
$values = wc_get_product_terms(
$product->get_id(),
$attr->get_name(),
[ 'fields' => 'names' ]
);
$value = $values ? implode( ', ', $values ) : '';
$label = wc_attribute_label( $attr->get_name() );
} else {
$options = (array) $attr->get_options();
$options = array_map( static function( $v ) { return wp_kses_post( $v ); }, $options );
$value = $options ? implode( ', ', $options ) : '';
$label = wc_attribute_label( $attr->get_name() );
}
if ( $value === '' ) {
continue;
}
$row_html = '
' . esc_html( $label ) . ':
' . esc_html( $value ) . '
';
// Приоритет: diametr-vnesnij-vnutrennij → затем diametr
if ( $slug === 'diametr-vnesnij-vnutrennij' ) {
$diam_vn_html = $row_html;
continue; // не добавляем в остаток
}
if ( $slug === 'diametr' ) {
$diam_fallback = $row_html;
continue; // не добавляем в остаток
}
// Остальные атрибуты — в конец
$remaining_rows[] = $row_html;
}
}
// Печатаем блок, если есть что выводить
if ( $diam_vn_html || $diam_fallback || $length_label !== '' || $weight !== '' || ! empty( $remaining_rows ) ) :
?>
Длина:
is_type('variable') ) :
?>
Вес 1 шт:
Цена 1 шт:
get_price();
$regular_price = (float) $product->get_regular_price();
// Сначала текущая цена
echo number_format_i18n( $price, 0 ) . ' ₽';
// Потом зачёркнутая цена (если есть скидка)
if ( $product->is_on_sale() && $regular_price > $price ) {
echo '';
echo number_format_i18n( $regular_price, 0 ) . ' ₽';
echo '';
}
?>