Корзина

cart->get_cart() as $cart_item_key => $cart_item ) { $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); // Получаем название товара без вариаций $product_name = $_product->get_name(); if ( $_product->is_type('variation') ) { $parent_product = wc_get_product( $cart_item['product_id'] ); if ( $parent_product ) { $product_name = $parent_product->get_name(); } } $product_name = apply_filters( 'woocommerce_cart_item_name', $product_name, $cart_item, $cart_item_key ); if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $cart_item, $cart_item_key ) ) { $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); ?> get_sku(); $weight = $_product->get_weight(); $qty = $cart_item['quantity']; $price = $_product->get_price(); $regular_price = $_product->get_regular_price(); $sale_price = $_product->get_sale_price(); $total_price = $price * $qty; $total_regular_price = $regular_price * $qty; $total_weight = $weight * $qty; ?>
get_image(), $cart_item, $cart_item_key ); if ( ! $product_permalink ) { echo $thumbnail; } else { printf( '%s', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok. } ?>

Код товара:

'; echo '

Толщина: ' . esc_html( $calc['thickness'] ) . ' мм

'; echo '

Ширина: ' . esc_html( $calc['width'] ) . ' мм

'; echo '

Длина: ' . esc_html( $calc['length'] ) . ' мм

'; // Итоговая цена за 1 лист после Длины echo '

Итоговая цена за 1 лист: ' . wc_price($price) . ''; if ($regular_price > $price) { echo ' ' . wc_price($regular_price) . ''; } echo '

'; echo '
'; } elseif ( $_product->is_type('variation') ) { $variation = wc_get_product( $cart_item['variation_id'] ); if ( $variation ) { // Проверяем ширину и длину для определения листового материала $width_meta = get_post_meta( $cart_item['variation_id'], '_variation_width', true ); if ( empty( $width_meta ) ) { $width_meta = $variation->get_width(); } $length_meta = get_post_meta( $cart_item['variation_id'], '_variation_length', true ); if ( empty( $length_meta ) ) { $length_meta = $variation->get_length(); } if ( $width_meta && $length_meta ) { // Листовые материалы — отображение как у оргстекла $attributes = $variation->get_variation_attributes(); $thickness_value = ''; foreach ( $attributes as $attr_key => $attr_value ) { $attr_slug = str_replace( 'attribute_pa_', '', $attr_key ); $attr_slug = str_replace( 'attribute_', '', $attr_slug ); if ( stripos( $attr_slug, 'ves' ) !== false ) { continue; } $taxonomy_name = str_replace( 'attribute_', '', $attr_key ); $term = get_term_by( 'slug', $attr_value, $taxonomy_name ); $thickness_value = $term ? $term->name : $attr_value; break; } echo '
'; if ( $thickness_value ) { $thickness_clean = preg_replace( '/\s*мм\s*$/u', '', $thickness_value ); $thickness_clean = preg_replace( '/\s*mm\s*$/i', '', $thickness_clean ); echo '

Толщина: ' . esc_html( trim( $thickness_clean ) ) . ' мм

'; } echo '

Ширина: ' . esc_html( $width_meta ) . ' мм

'; echo '

Длина: ' . esc_html( $length_meta ) . ' мм

'; echo '
'; } else { // Для остальных вариативных товаров (трубы/стержни/клей) $attributes = $variation->get_variation_attributes(); $has_params = false; $params_html = ''; foreach ( $attributes as $attr_key => $attr_value ) { $attr_slug = str_replace( 'attribute_pa_', '', $attr_key ); $attr_slug = str_replace( 'attribute_', '', $attr_slug ); if ( $attr_slug === 'ves' || $attr_slug === 'pa_ves' || stripos( $attr_slug, 'ves' ) !== false ) { continue; } $taxonomy_name = str_replace( 'attribute_', '', $attr_key ); $attr_name = ''; $attr_slug_clean = str_replace( 'pa_', '', $taxonomy_name ); $all_attr_taxonomies = wc_get_attribute_taxonomies(); foreach ( $all_attr_taxonomies as $tax ) { if ( $tax->attribute_name === $attr_slug_clean ) { $attr_name = $tax->attribute_label; break; } } if ( empty( $attr_name ) ) { $best_label = ''; $best_dist = PHP_INT_MAX; foreach ( $all_attr_taxonomies as $tax ) { $dist = levenshtein( $attr_slug_clean, $tax->attribute_name ); if ( $dist < $best_dist && $dist <= 3 ) { $best_dist = $dist; $best_label = $tax->attribute_label; } } if ( ! empty( $best_label ) ) { $attr_name = $best_label; } } if ( empty( $attr_name ) ) { $attr_name = wc_attribute_label( $taxonomy_name ); } $term = get_term_by( 'slug', $attr_value, $taxonomy_name ); $attr_value_display = $term ? $term->name : $attr_value; $attr_value_display = str_replace( array( ' mm', 'mm' ), ' мм', $attr_value_display ); $params_html .= '

' . esc_html( $attr_name ) . ': ' . esc_html( $attr_value_display ) . '

'; $has_params = true; } $length_only = get_post_meta( $cart_item['variation_id'], '_variation_length', true ); if ( empty( $length_only ) ) { $length_only = $variation->get_length(); } if ( $length_only ) { $params_html .= '

Длина: ' . esc_html( $length_only ) . ' мм

'; $has_params = true; } if ( $has_params ) { echo '
' . $params_html . '
'; } } } } // Для простых товаров (клей) - НЕ показываем вес здесь, он уже есть в cart-product__chars ?>
0 ? $price / $weight : 0 ); ?>

Итоговая цена за 1 кг:

Вес:

кг

Вес 1 :

кг

Итоговая цена за 1 :

$price): ?>

Количество

is_sold_individually() ) { $min_quantity = 1; $max_quantity = 1; } else { $min_quantity = 0; $max_quantity = $_product->get_max_purchase_quantity(); } $product_quantity = woocommerce_quantity_input( array( 'input_name' => "cart[{$cart_item_key}][qty]", 'input_value' => $cart_item['quantity'], 'max_value' => $max_quantity, 'min_value' => $min_quantity, 'product_name' => $product_name, ), $_product, false ); echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item ); ?>
Удалить
is_type('variation') ? $_product->get_parent_id() : $_product->get_id(); // Показываем статусные теги (не скидки) if ( function_exists('get_sorted_product_tags') && function_exists('is_discount_tag') ) { $sorted_tags = get_sorted_product_tags( $product_id_for_tags ); foreach ( $sorted_tags as $tag ) { if ( ! is_discount_tag( $tag->name ) ) { echo ''; } } } // Получаем процент скидки из тегов товара $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_id_for_tags ); foreach ( $tags as $tag ) { if ( is_discount_tag( $tag->name ) ) { $discount_percent = get_discount_from_tag_name( $tag->name ); break; } } } if ( $discount_percent > 0 ) : ?>

-%

Итоговая стоимость:

$total_price): ?>

Итоговый вес:

кг

Ваш заказ

cart->get_cart_contents_count(); function plural_form($number, $forms) { $n = abs($number) % 100; $n1 = $n % 10; if ($n > 10 && $n < 20) return $forms[2]; if ($n1 > 1 && $n1 < 5) return $forms[1]; if ($n1 == 1) return $forms[0]; return $forms[2]; } $word = plural_form($count, ['товар', 'товара', 'товаров']); ?>

Количество товаров:

cart; $total_weight = 0; foreach ( $cart->get_cart() as $item ) { $product = $item['data']; $qty = $item['quantity']; $weight = (float) $product->get_weight(); $total_weight += $weight * $qty; } ?>

Вес заказа:

кг

cart; $items = $cart->get_cart(); $regular_total = 0; $sale_total = 0; foreach ( $items as $item ) { $product = $item['data']; $quantity = $item['quantity']; $regular_price = $product->get_regular_price(); $sale_price = $product->get_sale_price(); if ( $sale_price === '' ) { $sale_price = $regular_price; } $regular_total += $regular_price * $quantity; $sale_total += $sale_price * $quantity; } // Округляем суммы $regular_total = round($regular_total); $sale_total = round($sale_total); // Скидка на товары $product_discount = $regular_total - $sale_total; // Скидка от суммы заказа (порог проверяется по сумме СО скидками на товары) $cart_discount = function_exists('orgsteklo_calculate_cart_discount') ? orgsteklo_calculate_cart_discount( $sale_total ) : array( 'percent' => 0, 'amount' => 0 ); $discount_from_total = $cart_discount['amount']; // Итоговая сумма $final_total = $sale_total - $discount_from_total; ?>

Стоимость товара без скидки:

Скидка на товар:

0 ) : ?>

Скидка от суммы заказа (%):

Стоимость заказа:

$final_total ) : ?>

Перейти к оформлению заказа

Доступные способы доставки и оплаты можно выбрать при оформлении заказа.

Войти, чтобы отслеживать статус заказа.