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 ''; } ?>
Область применения'; } if($documentation_repeat_repeats) { echo ''; } ?>

Область применения

'; } if($documentation_repeat_repeats) { echo ''; } ?>

Характеристики и свойства

Область применения

' . $product_description . '
'; } if($documentation_repeat_repeats) { echo '

Документация для скачивания

'; foreach ($documentation_repeat_repeats as $index => $documentation_repeat_repeat) { $documentation_repeat_repeat_title = $documentation_repeat_repeat['documentation_repeat_repeat_title']; $documentation_repeat_repeat_format = $documentation_repeat_repeat['documentation_repeat_repeat_format']; $documentation_repeat_repeat_razmer = $documentation_repeat_repeat['documentation_repeat_repeat_razmer']; $documentation_repeat_repeat_file = $documentation_repeat_repeat['documentation_repeat_repeat_file']; $documentation_repeat_repeat_file_url = $documentation_repeat_repeat_file ? esc_url($documentation_repeat_repeat_file['url']) : ''; echo '
'; echo '' . $documentation_repeat_repeat_title . ''; echo '
'; echo '
'; if($documentation_repeat_repeat_format) { echo '

' . $documentation_repeat_repeat_format . '

'; } if($documentation_repeat_repeat_razmer) { echo '

' . $documentation_repeat_repeat_razmer . '

'; } echo '
'; echo ''; // оставить SVG как есть echo '
'; echo '
'; echo '' . $documentation_repeat_repeat_title . ''; echo '
'; if($documentation_repeat_repeat_format) { echo '

' . $documentation_repeat_repeat_format . '

'; } if($documentation_repeat_repeat_razmer) { echo '

' . $documentation_repeat_repeat_razmer . '

'; } echo '
'; echo '
'; echo '
'; } echo '
'; } ?>
get_id(), 'product_cat', array( 'fields' => 'ids' ) ); // Расширяем до родительской категории и всех её дочерних $all_categories = $categories; foreach ( $categories as $cat_id ) { $ancestors = get_ancestors( $cat_id, 'product_cat' ); $all_categories = array_merge( $all_categories, $ancestors ); foreach ( $ancestors as $ancestor_id ) { $children = get_term_children( $ancestor_id, 'product_cat' ); $all_categories = array_merge( $all_categories, $children ); } } $categories = array_unique( $all_categories ); // Рекомендуемые товары: только с _is_recommended_product = 'yes' из той же категории $recommended_args = array( 'post_type' => 'product', 'posts_per_page' => 8, 'post__not_in' => array( $product->get_id() ), 'ignore_sticky_posts' => 1, 'post_status' => array( 'publish', 'draft' ), 'orderby' => 'rand', 'meta_query' => array( array( 'key' => '_is_recommended_product', 'value' => 'yes', ), ), 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $categories, 'operator' => 'IN', ), ), ); $recommended_query = new WP_Query( $recommended_args ); $all_products = $recommended_query->posts; if ( ! empty( $all_products ) ) : global $post; echo '

Рекомендуемые товары

Все товары
'; foreach ( $all_products as $related_product ) : $post = $related_product; setup_postdata( $post ); echo '
'; wc_get_template_part( 'content', 'product' ); echo '
'; endforeach; wp_reset_postdata(); echo '
'; foreach ( $all_products as $related_product ) : $post = $related_product; setup_postdata( $post ); wc_get_template_part( 'content', 'product' ); endforeach; wp_reset_postdata(); echo '
Все товары
'; endif; ?>