is_visible() ) { return; } $current_product_id = get_the_ID(); ?>
get_id(); $product_link = get_permalink( $product_id ); echo ''; $product_image_id = $product->get_image_id(); if ( $product_image_id ) { $image_url = wp_get_attachment_image_url( $product_image_id, 'full' ); echo '' . esc_attr( $product->get_name() ) . ''; } else { $placeholder_url = wc_placeholder_img_src( 'woocommerce_single' ); echo '' . esc_attr( $product->get_name() ) . ''; } echo ''; ?> '; // Выводим все метки (статусные и скидки) // Теперь метки со скидками автоматически применяют скидку к цене через хуки foreach ( $sorted_tags as $tag ) { $is_discount = is_discount_tag( $tag->name ); $class = $is_discount ? 'product_item-discount' : 'product_item-popular'; echo '

' . esc_html( $tag->name ) . '

'; } echo '
'; } ?>
get_name() ); ?> get_id(), '_preview_char_1', true ); $char_2 = get_post_meta( $product->get_id(), '_preview_char_2', true ); if ( $char_1 || $char_2 ) { echo ''; } ?>
is_type( 'variable' ) ) { $available_variations = $product->get_available_variations(); $variation_id = $available_variations[0]['variation_id'] ?? null; if ( $variation_id ) { $display_product = wc_get_product( $variation_id ); } } // Получаем цены (с учётом автоматических скидок по меткам) $price = wc_get_price_to_display( $display_product ); $regular_price = wc_get_price_to_display( $display_product, [ 'price' => $display_product->get_regular_price() ] ); // Проверяем, является ли товар оргстеклом $is_orgsteklo_product = ! empty( get_post_meta( $product->get_id(), '_orgsteklo_price_table', true ) ); if ( $is_orgsteklo_product && function_exists( 'orgsteklo_get_product_table_data' ) && function_exists( 'orgsteklo_calculate_standard_size' ) ) { // ОРГСТЕКЛО — цены из таблицы калькулятора $table_data = orgsteklo_get_product_table_data( $product->get_id() ); if ( $table_data && ! empty( $table_data['rows'] ) ) { $first_row = $table_data['rows'][0]; $calc_result = orgsteklo_calculate_standard_size( $product->get_id(), $first_row['thickness'], 1 ); if ( ! is_wp_error( $calc_result ) ) { $sheet_price = $calc_result['price_standard_sheet']; $kg_price = $calc_result['price_per_kg_standard']; // Проверяем скидку из тегов $discount_percent = 0; if ( function_exists('get_sorted_product_tags') && function_exists('is_discount_tag') && function_exists('get_discount_from_tag_name') ) { $tags = get_sorted_product_tags( $product->get_id() ); foreach ( $tags as $tag ) { if ( is_discount_tag( $tag->name ) ) { $discount_percent = get_discount_from_tag_name( $tag->name ); break; } } } $regular_sheet_price = $sheet_price; $regular_kg_price = $kg_price; if ( $discount_percent > 0 ) { $sheet_price = round( $regular_sheet_price * ( 1 - $discount_percent / 100 ) ); $kg_price = round( $regular_kg_price * ( 1 - $discount_percent / 100 ) ); } // Цена за лист echo '
'; echo '

' . wc_price( $sheet_price ) . '/лист

'; if ( $discount_percent > 0 ) { echo '

' . wc_price( $regular_sheet_price ) . '

'; } echo '
'; // Цена за кг echo '
'; echo '

' . wc_price( $kg_price ) . '/кг

'; if ( $discount_percent > 0 ) { echo '

' . wc_price( $regular_kg_price ) . '

'; } echo '
'; } } } else { // Остальные товары — цена за штуку echo '
'; echo '

' . wc_price( $price ) . '/штука

'; if ( $regular_price > $price ) { echo '

' . wc_price( $regular_price ) . '

'; } echo '
'; } } ?>
Подробнее