Jamil-Abdullayev b8246597d4 Initial commit: orgsteklo WordPress theme
Custom WooCommerce theme for orgsteklo.ru including:
- Product catalog with category/subcategory hierarchy
- Custom checkout with delivery calculation
- Price calculator
- Admin settings panel
- Search functionality
- User account pages
2026-03-05 00:48:06 +04:00

466 lines
37 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
<?php
if (is_category()) {
single_cat_title();
} elseif (is_tag()) {
single_tag_title();
} elseif (is_tax()) {
single_term_title();
} elseif (is_post_type_archive()) {
post_type_archive_title();
} elseif (is_archive()) {
the_archive_title();
} elseif (is_search()) {
echo 'Результаты поиска: ' . get_search_query();
} elseif (is_404()) {
echo 'Страница не найдена';
} elseif (is_home()) {
bloginfo('name');
} elseif (is_singular()) {
echo get_the_title();
} else {
wp_title('');
}
?>
</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap" rel="stylesheet">
<link rel="icon" href="/wp-content/uploads/2025/04/vector.svg">
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<header>
<div class="header-top">
<div class="header-top__container container">
<?php
$logo = get_field('logo', 'option');
if ($logo) {
echo '<a href="/" class="logo">';
echo '<img src="' . esc_url($logo['url']) . '" alt="' . esc_attr($logo['alt']) . '">';
echo '</a>';
}
?>
<div class="header-top__row">
<?php
$menu_items = wp_get_nav_menu_items('Основное меню');
if ($menu_items) {
$menu_tree = [];
foreach ($menu_items as $item) {
$parent_id = $item->menu_item_parent ? $item->menu_item_parent : 0;
$menu_tree[$parent_id][] = $item;
}
function render_menu($parent_id, $menu_tree) {
if (!isset($menu_tree[$parent_id])) {
return;
}
echo '<ul' . ($parent_id === 0 ? ' class="topmenu"' : ' class="submenu"') . '>';
foreach ($menu_tree[$parent_id] as $item) {
$has_children = isset($menu_tree[$item->ID]);
$is_active = is_page($item->object_id) ? ' class="active"' : '';
echo '<li>';
echo '<a href="' . esc_url($item->url) . '"' . $is_active . '>' . esc_html($item->title);
if ($has_children) {
echo ' <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.96036 4.08984H5.84536H3.04036C2.56036 4.08984 2.32036 4.66984 2.66036 5.00984L5.25036 7.59984C5.66536 8.01484 6.34036 8.01484 6.75536 7.59984L7.74036 6.61484L9.34536 5.00984C9.68036 4.66984 9.44036 4.08984 8.96036 4.08984Z" fill="#808080"/</svg>';
}
echo '</a>';
if ($has_children) {
render_menu($item->ID, $menu_tree);
}
echo '</li>';
}
echo '</ul>';
}
echo '<nav>';
render_menu(0, $menu_tree);
echo '</nav>';
}
?>
<div class="header-contacts">
<?php
$phone = get_field('phone', 'option');
if ($phone) {
echo '<a href="tel:' . $phone . '"><svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_3001_6929)"><path d="M7.02375 1.00005C8.04288 1.10743 8.99483 1.55945 9.72218 2.28134C10.4495 3.00323 10.9087 3.95175 11.0237 4.97005M7.02375 3.00005C7.5155 3.09702 7.96675 3.33956 8.31894 3.6962C8.67112 4.05284 8.90797 4.50711 8.99875 5.00005M10.9987 8.46005V9.96005C10.9993 10.0993 10.9708 10.2371 10.915 10.3647C10.8592 10.4923 10.7774 10.6068 10.6748 10.701C10.5722 10.7951 10.451 10.8668 10.3191 10.9114C10.1872 10.956 10.0474 10.9726 9.90875 10.96C8.37016 10.7929 6.89225 10.2671 5.59375 9.42505C4.38566 8.65738 3.36141 7.63313 2.59375 6.42505C1.74873 5.12065 1.22287 3.63555 1.05875 2.09005C1.04625 1.95178 1.06268 1.81243 1.107 1.68086C1.15131 1.54929 1.22253 1.42839 1.31613 1.32586C1.40973 1.22332 1.52365 1.1414 1.65064 1.08531C1.77763 1.02922 1.91492 1.00018 2.05375 1.00005H3.55375C3.7964 0.99766 4.03164 1.08359 4.21563 1.24181C4.39961 1.40004 4.51978 1.61977 4.55375 1.86005C4.61706 2.34008 4.73447 2.81141 4.90375 3.26505C4.97102 3.44401 4.98558 3.63851 4.9457 3.82549C4.90582 4.01247 4.81318 4.1841 4.67875 4.32005L4.04375 4.95505C4.75552 6.20682 5.79197 7.24327 7.04375 7.95505L7.67875 7.32005C7.81469 7.18562 7.98632 7.09297 8.17331 7.0531C8.36029 7.01322 8.55478 7.02778 8.73375 7.09505C9.18738 7.26432 9.65871 7.38174 10.1387 7.44505C10.3816 7.47931 10.6034 7.60165 10.762 7.7888C10.9206 7.97594 11.0048 8.21484 10.9987 8.46005Z" stroke="#808080" stroke-linecap="round" stroke-linejoin="round"/></g><defs><clipPath id="clip0_3001_6929"><rect width="12" height="12" fill="white"/></clipPath></defs></svg>' . $phone . '</a>';
}
?>
<?php
$email = get_field('email', 'option');
if ($email) {
echo '<a href="mailto:' . $email . '"><svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11 3.5L6.515 6.35C6.36064 6.44671 6.18216 6.49801 6 6.49801C5.81784 6.49801 5.63936 6.44671 5.485 6.35L1 3.5M2 2H10C10.5523 2 11 2.44772 11 3V9C11 9.55228 10.5523 10 10 10H2C1.44772 10 1 9.55228 1 9V3C1 2.44772 1.44772 2 2 2Z" stroke="#808080" stroke-linecap="round" stroke-linejoin="round"/></svg>' . $email . '</a>';
}
?>
</div>
</div>
<div class="header-top__mob">
<?php
$phone = get_field('phone', 'option');
if ($phone) {
echo '<a href="tel:' . $phone . '"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_3008_21213)"><path d="M9.36499 1.33356C10.7238 1.47674 11.9931 2.07943 12.9629 3.04195C13.9327 4.00447 14.5449 5.26917 14.6983 6.62689M9.36499 4.00023C10.0207 4.12952 10.6223 4.45291 11.0919 4.92843C11.5615 5.40395 11.8773 6.00965 11.9983 6.66689M14.665 11.2802V13.2802C14.6657 13.4659 14.6277 13.6497 14.5533 13.8198C14.479 13.9899 14.3699 14.1426 14.233 14.2681C14.0962 14.3937 13.9347 14.4892 13.7588 14.5487C13.5829 14.6082 13.3966 14.6303 13.2117 14.6136C11.1602 14.3907 9.18966 13.6897 7.45833 12.5669C5.84755 11.5433 4.48189 10.1777 3.45833 8.56689C2.33165 6.8277 1.63049 4.84756 1.41166 2.78689C1.395 2.60254 1.41691 2.41673 1.47599 2.24131C1.53508 2.06589 1.63004 1.90469 1.75484 1.76797C1.87964 1.63126 2.03153 1.52203 2.20086 1.44724C2.37018 1.37245 2.55322 1.33374 2.73833 1.33356H4.73833C5.06187 1.33038 5.37552 1.44495 5.62084 1.65592C5.86615 1.86689 6.02638 2.15986 6.07166 2.48023C6.15608 3.12027 6.31263 3.74871 6.53833 4.35356C6.62802 4.59218 6.64744 4.8515 6.59427 5.10081C6.54109 5.35012 6.41757 5.57897 6.23833 5.76023L5.39166 6.60689C6.3407 8.27592 7.72263 9.65786 9.39166 10.6069L10.2383 9.76023C10.4196 9.58099 10.6484 9.45746 10.8977 9.40429C11.1471 9.35112 11.4064 9.37053 11.645 9.46023C12.2498 9.68593 12.8783 9.84248 13.5183 9.92689C13.8422 9.97258 14.1379 10.1357 14.3493 10.3852C14.5608 10.6348 14.6731 10.9533 14.665 11.2802Z" stroke="#C4C4C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></g><defs><clipPath id="clip0_3008_21213"><rect width="16" height="16" fill="white"/></clipPath></defs></svg></a>';
}
?>
<?php
$email = get_field('email', 'option');
if ($email) {
echo '<a href="mailto:' . $email . '"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.6663 4.6665L8.68634 8.4665C8.48052 8.59545 8.24255 8.66384 7.99967 8.66384C7.7568 8.66384 7.51883 8.59545 7.31301 8.4665L1.33301 4.6665M2.66634 2.6665H13.333C14.0694 2.6665 14.6663 3.26346 14.6663 3.99984V11.9998C14.6663 12.7362 14.0694 13.3332 13.333 13.3332H2.66634C1.92996 13.3332 1.33301 12.7362 1.33301 11.9998V3.99984C1.33301 3.26346 1.92996 2.6665 2.66634 2.6665Z" stroke="#C4C4C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg></a>';
}
?>
<button class="minicart-open"><span>00</span><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_3008_21223)"><path d="M1.36621 1.36719H2.69954L4.47288 9.64719C4.53793 9.95043 4.70666 10.2215 4.95002 10.4138C5.19338 10.606 5.49615 10.7074 5.80621 10.7005H12.3262C12.6297 10.7 12.9239 10.596 13.1602 10.4057C13.3966 10.2154 13.561 9.95021 13.6262 9.65385L14.7262 4.70052H3.41288M5.99954 14.0005C5.99954 14.3687 5.70107 14.6672 5.33288 14.6672C4.96469 14.6672 4.66621 14.3687 4.66621 14.0005C4.66621 13.6323 4.96469 13.3339 5.33288 13.3339C5.70107 13.3339 5.99954 13.6323 5.99954 14.0005ZM13.3329 14.0005C13.3329 14.3687 13.0344 14.6672 12.6662 14.6672C12.298 14.6672 11.9995 14.3687 11.9995 14.0005C11.9995 13.6323 12.298 13.3339 12.6662 13.3339C13.0344 13.3339 13.3329 13.6323 13.3329 14.0005Z" stroke="#C4C4C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></g><defs><clipPath id="clip0_3008_21223"><rect width="16" height="16" fill="white"/></clipPath></defs></svg></button>
<a href=""><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.00033 8.66667C9.84127 8.66667 11.3337 7.17428 11.3337 5.33333C11.3337 3.49238 9.84127 2 8.00033 2C6.15938 2 4.66699 3.49238 4.66699 5.33333C4.66699 7.17428 6.15938 8.66667 8.00033 8.66667ZM8.00033 8.66667C9.41481 8.66667 10.7714 9.22857 11.7716 10.2288C12.7718 11.229 13.3337 12.5855 13.3337 14M8.00033 8.66667C6.58584 8.66667 5.22928 9.22857 4.22909 10.2288C3.2289 11.229 2.66699 12.5855 2.66699 14" stroke="#C4C4C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg></a>
</div>
</div>
</div>
<div class="header-bottom">
<div class="header-bottom__container container">
<button class="header-catalog__button-mob" onclick="toggleMenu2(this)">
<div class="header-catalog__button-icon">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</div>
</button>
<div class="header-bottom__row">
<button class="header-catalog__button <?php if ( is_front_page() ) echo 'change'; ?>" onclick="toggleMenu(this)">
<div class="header-catalog__button-icon">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</div>
<p>Каталог товаров</p>
</button>
<form role="search" method="get" class="header-search" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label class="screen-reader-text" for="s"><?php _e( 'Результат поиска:', 'woocommerce' ); ?></label>
<input type="search" id="s" placeholder="Я ищу..." value="<?php echo get_search_query(); ?>" name="s" required>
<button class="header-search__submit" type="submit" value="<?php echo esc_attr_x( 'Search', 'submit button', 'woocommerce' ); ?>">
<p>Найти</p>
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_3001_6954)"><path d="M13.8292 13.0049L10.3473 9.52294C11.2961 8.36245 11.7627 6.88166 11.6504 5.38685C11.538 3.89204 10.8555 2.49758 9.74388 1.49191C8.63226 0.486236 7.17663 -0.0537076 5.67807 -0.0162391C4.17952 0.0212295 2.75269 0.633244 1.69272 1.69321C0.632756 2.75318 0.0207412 4.18001 -0.0167273 5.67856C-0.0541959 7.17712 0.485748 8.63275 1.49142 9.74436C2.49709 10.856 3.89155 11.5385 5.38636 11.6508C6.88117 11.7632 8.36197 11.2966 9.52245 10.3478L13.0044 13.8297C13.1144 13.9359 13.2617 13.9947 13.4147 13.9934C13.5676 13.9921 13.7139 13.9307 13.8221 13.8226C13.9303 13.7144 13.9916 13.5681 13.9929 13.4152C13.9943 13.2622 13.9355 13.1149 13.8292 13.0049ZM5.83345 10.5006C4.91047 10.5006 4.00822 10.2269 3.24079 9.71413C2.47336 9.20135 1.87522 8.47252 1.52201 7.61979C1.1688 6.76707 1.07639 5.82876 1.25645 4.92352C1.43652 4.01827 1.88097 3.18675 2.53362 2.53411C3.18626 1.88146 4.01778 1.437 4.92303 1.25694C5.82827 1.07688 6.76658 1.16929 7.61931 1.5225C8.47203 1.87571 9.20086 2.47385 9.71364 3.24128C10.2264 4.00871 10.5001 4.91096 10.5001 5.83394C10.4987 7.07119 10.0066 8.25737 9.13175 9.13224C8.25688 10.0071 7.0707 10.4992 5.83345 10.5006Z" fill="white"/></g><defs><clipPath id="clip0_3001_6954"><rect width="14" height="14" fill="white"/></clipPath></defs></svg>
</button>
<input type="hidden" name="post_type" value="product" />
</form>
</div>
<div class="header-bottom__buttons">
<button class="header-cart minicart-open">
<div class="header-cart__icon">
<span class="header-cart__count"><?php echo WC()->cart->get_cart_contents_count(); ?></span>
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.7334 2.73438H5.40007L8.94673 19.2944C9.07684 19.9009 9.41429 20.443 9.90101 20.8275C10.3877 21.212 10.9933 21.4148 11.6134 21.401H24.6534C25.2603 21.4001 25.8487 21.1921 26.3214 20.8115C26.7942 20.4309 27.1229 19.9004 27.2534 19.3077L29.4534 9.40104H6.82673M12.0001 28.001C12.0001 28.7374 11.4031 29.3344 10.6667 29.3344C9.93035 29.3344 9.3334 28.7374 9.3334 28.001C9.3334 27.2647 9.93035 26.6677 10.6667 26.6677C11.4031 26.6677 12.0001 27.2647 12.0001 28.001ZM26.6667 28.001C26.6667 28.7374 26.0698 29.3344 25.3334 29.3344C24.597 29.3344 24.0001 28.7374 24.0001 28.001C24.0001 27.2647 24.597 26.6677 25.3334 26.6677C26.0698 26.6677 26.6667 27.2647 26.6667 28.001Z" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
</div>
Корзина
</button>
<?php if ( is_user_logged_in() ) : ?>
<a href="/account" class="header-login"><svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.9997 17.3333C19.6816 17.3333 22.6663 14.3486 22.6663 10.6667C22.6663 6.98477 19.6816 4 15.9997 4C12.3178 4 9.33301 6.98477 9.33301 10.6667C9.33301 14.3486 12.3178 17.3333 15.9997 17.3333ZM15.9997 17.3333C18.8286 17.3333 21.5418 18.4571 23.5421 20.4575C25.5425 22.4579 26.6663 25.171 26.6663 28M15.9997 17.3333C13.1707 17.3333 10.4576 18.4571 8.4572 20.4575C6.45681 22.4579 5.33301 25.171 5.33301 28" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>Аккаунт</a>
<?php else : ?>
<a href="/login" class="header-login"><svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.9997 17.3333C19.6816 17.3333 22.6663 14.3486 22.6663 10.6667C22.6663 6.98477 19.6816 4 15.9997 4C12.3178 4 9.33301 6.98477 9.33301 10.6667C9.33301 14.3486 12.3178 17.3333 15.9997 17.3333ZM15.9997 17.3333C18.8286 17.3333 21.5418 18.4571 23.5421 20.4575C25.5425 22.4579 26.6663 25.171 26.6663 28M15.9997 17.3333C13.1707 17.3333 10.4576 18.4571 8.4572 20.4575C6.45681 22.4579 5.33301 25.171 5.33301 28" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>Войти</a>
<?php endif; ?>
</div>
</div>
</div>
</header>
<div class="minicart__fon"></div>
<div class="minicart">
<h4>Товары в корзине (<span class="header-cart__count"><?php echo WC()->cart->get_cart_contents_count(); ?></span>)</h4>
<?php $cart_count = WC()->cart->get_cart_contents_count();?>
<div class="minicart-products">
<?php
foreach ( WC()->cart->get_cart() as $cart_item ) :
$product = $cart_item['data'];
if ( ! $product || ! $product->exists() ) continue;
// Получаем название товара без вариаций
$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();
}
}
?>
<div class="minicart-product" data-product-id="<?php echo $cart_item['product_id']; ?>">
<a href="<?php echo get_permalink( $cart_item['product_id'] ); ?>" class="minicart-product__img">
<img src="<?php echo get_the_post_thumbnail_url( $cart_item['product_id'], 'thumbnail' ); ?>" alt="<?php echo esc_attr( $product_name ); ?>">
</a>
<div class="minicart-product__main">
<a href="<?php echo get_permalink( $cart_item['product_id'] ); ?>" class="minicart-product__title">
<?php
echo $product_name;
// Добавляем количество
$unit = 'ШТ';
if ( isset( $cart_item['orgsteklo_calculator'] ) ) {
$unit = 'ЛИСТ';
}
echo ' <span style="color: #666;">(' . $cart_item['quantity'] . $unit . ')</span>';
?>
</a>
<div class="minicart-product__row">
<?php
// Use same logic as cart.php
$regular_price = $product->get_regular_price();
$sale_price = $product->get_sale_price();
if ( $sale_price === '' ) {
$sale_price = $regular_price;
}
$line_regular = $regular_price * $cart_item['quantity'];
$line_sale = $sale_price * $cart_item['quantity'];
if ( $line_regular > $line_sale ) {
echo '<p class="minicart-product__price">' . wc_price( $line_sale ) . ' <del class="minicart-product__oldprice">' . wc_price( $line_regular ) . '</del></p>';
} else {
echo '<p class="minicart-product__price">' . wc_price( $line_sale ) . '</p>';
}
?>
<button class="minicart-product__delete" data-id="<?php echo $cart_item['product_id']; ?>"><svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_1149_35638)"><path d="M17.4993 3.83333H14.916C14.7226 2.89284 14.2109 2.04779 13.4671 1.4406C12.7233 0.833408 11.7929 0.501212 10.8327 0.5L9.16602 0.5C8.20584 0.501212 7.27545 0.833408 6.53164 1.4406C5.78783 2.04779 5.2761 2.89284 5.08268 3.83333H2.49935C2.27834 3.83333 2.06637 3.92113 1.91009 4.07741C1.75381 4.23369 1.66602 4.44565 1.66602 4.66667C1.66602 4.88768 1.75381 5.09964 1.91009 5.25592C2.06637 5.4122 2.27834 5.5 2.49935 5.5H3.33268V16.3333C3.33401 17.438 3.77342 18.497 4.55453 19.2782C5.33565 20.0593 6.39469 20.4987 7.49935 20.5H12.4993C13.604 20.4987 14.6631 20.0593 15.4442 19.2782C16.2253 18.497 16.6647 17.438 16.666 16.3333V5.5H17.4993C17.7204 5.5 17.9323 5.4122 18.0886 5.25592C18.2449 5.09964 18.3327 4.88768 18.3327 4.66667C18.3327 4.44565 18.2449 4.23369 18.0886 4.07741C17.9323 3.92113 17.7204 3.83333 17.4993 3.83333ZM9.16602 2.16667H10.8327C11.3496 2.1673 11.8536 2.32781 12.2757 2.6262C12.6978 2.92459 13.0172 3.34624 13.1902 3.83333H6.80852C6.9815 3.34624 7.30093 2.92459 7.723 2.6262C8.14508 2.32781 8.64912 2.1673 9.16602 2.16667ZM14.9993 16.3333C14.9993 16.9964 14.736 17.6323 14.2671 18.1011C13.7983 18.5699 13.1624 18.8333 12.4993 18.8333H7.49935C6.83631 18.8333 6.20042 18.5699 5.73158 18.1011C5.26274 17.6323 4.99935 16.9964 4.99935 16.3333V5.5H14.9993V16.3333Z" fill="#C4C4C4"/><path d="M8.33333 15.4997C8.55434 15.4997 8.76631 15.4119 8.92259 15.2556C9.07887 15.0993 9.16666 14.8873 9.16666 14.6663V9.66634C9.16666 9.44533 9.07887 9.23337 8.92259 9.07709C8.76631 8.92081 8.55434 8.83301 8.33333 8.83301C8.11232 8.83301 7.90036 8.92081 7.74408 9.07709C7.5878 9.23337 7.5 9.44533 7.5 9.66634V14.6663C7.5 14.8873 7.5878 15.0993 7.74408 15.2556C7.90036 15.4119 8.11232 15.4997 8.33333 15.4997Z" fill="#C4C4C4"/><path d="M11.6673 15.4997C11.8883 15.4997 12.1003 15.4119 12.2566 15.2556C12.4129 15.0993 12.5007 14.8873 12.5007 14.6663V9.66634C12.5007 9.44533 12.4129 9.23337 12.2566 9.07709C12.1003 8.92081 11.8883 8.83301 11.6673 8.83301C11.4463 8.83301 11.2343 8.92081 11.0781 9.07709C10.9218 9.23337 10.834 9.44533 10.834 9.66634V14.6663C10.834 14.8873 10.9218 15.0993 11.0781 15.2556C11.2343 15.4119 11.4463 15.4997 11.6673 15.4997Z" fill="#C4C4C4"/></g><defs><clipPath id="clip0_1149_35638"><rect width="20" height="20" fill="white" transform="translate(0 0.5)"/></clipPath></defs></svg></button>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="minicart-bottom">
<div class="minicart-prices">
<p class="minicart-price__title">Стоимость заказа:</p>
<?php
// Use same logic as cart.php
$regular_total = 0;
$sale_total = 0;
foreach ( WC()->cart->get_cart() as $cart_item ) {
$product = $cart_item['data'];
if ( ! $product ) continue;
$quantity = $cart_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;
}
// Применяем скидку от суммы заказа (порог проверяется по сумме СО скидками на товары)
$cart_discount = function_exists('orgsteklo_calculate_cart_discount')
? orgsteklo_calculate_cart_discount( $sale_total )
: array( 'percent' => 0, 'amount' => 0 );
$final_total = $sale_total - $cart_discount['amount'];
if ( $regular_total > $final_total ) {
echo '<p class="minicart-price">' . number_format($final_total, 0, ',', ' ') . ' ₽ <del class="minicart-price__old">' . number_format($regular_total, 0, ',', ' ') . ' ₽</del></p>';
} else {
echo '<p class="minicart-price">' . number_format($final_total, 0, ',', ' ') . ' ₽</p>';
}
?>
</div>
<a href="/cart" class="minicart-link">
<p>Перейти в корзину</p>
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10.8242 4.44727L15.3767 8.99977L10.8242 13.5523" stroke="white" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/><path d="M2.625 9H15.2475" stroke="white" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/></svg>
</a>
</div>
</div>
<div class="pc_menu__fon"></div>
<div class="pc_menu pc_menu-home <?php if ( is_front_page() ) echo 'active'; ?>">
<?php
function render_product_categories_menu($parent_id = 0)
{
$exclude_term = get_term_by('name', 'Misc', 'product_cat');
$exclude_id = $exclude_term ? $exclude_term->term_id : 0;
$args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'parent' => $parent_id,
'exclude' => array($exclude_id),
'orderby' => 'menu_order',
'order' => 'ASC',
);
$categories = get_terms($args);
foreach ($categories as $category) {
$child_args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'parent' => $category->term_id,
);
$children = get_terms($child_args);
$has_children = !empty($children);
echo '<li>';
echo '<a href="' . get_term_link($category) . '" class="pc_menu-link">';
echo '<div class="pc_menu-link__row">';
$icon = get_field('category_icon', 'product_cat_' . $category->term_id);
$icon_url = $icon ? $icon['url'] : get_template_directory_uri() . '/assets/images/catalog_icon.png';
echo '<img src="' . esc_url($icon_url) . '" alt="">';
echo esc_html($category->name);
echo '</div>';
if ($has_children) {
echo '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.96036 4.08984H5.84536H3.04036C2.56036 4.08984 2.32036 4.66984 2.66036 5.00984L5.25036 7.59984C5.66536 8.01484 6.34036 8.01484 6.75536 7.59984L7.74036 6.61484L9.34536 5.00984C9.68036 4.66984 9.44036 4.08984 8.96036 4.08984Z" fill="#808080"/></svg>';
}
echo '</a>';
if ($has_children) {
echo '<ul class="submenu">';
render_product_categories_menu($category->term_id);
echo '</ul>';
}
echo '</li>';
}
}
?>
<nav>
<ul class="topmenu">
<?php render_product_categories_menu(); ?>
</ul>
</nav>
</div>
<div class="menu_mob">
<?php
$logo = get_field('logo', 'option');
if ($logo) {
echo '<a href="/" class="menu_mob-logo">';
echo '<img src="' . esc_url($logo['url']) . '" alt="' . esc_attr($logo['alt']) . '">';
echo '</a>';
}
?>
<button class="menu_mob-close"><svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_1163_32333)"><path d="M19.7561 0.244477C19.5999 0.0882511 19.3879 0.000488281 19.167 0.000488281C18.946 0.000488281 18.7341 0.0882511 18.5778 0.244477L10.0003 8.82198L1.42281 0.244477C1.26654 0.0882511 1.05461 0.000488281 0.833644 0.000488281C0.612674 0.000488281 0.40075 0.0882511 0.244477 0.244477C0.0882511 0.40075 0.000488281 0.612674 0.000488281 0.833644C0.000488281 1.05461 0.0882511 1.26654 0.244477 1.42281L8.82198 10.0003L0.244477 18.5778C0.0882511 18.7341 0.000488281 18.946 0.000488281 19.167C0.000488281 19.3879 0.0882511 19.5999 0.244477 19.7561C0.40075 19.9124 0.612674 20.0001 0.833644 20.0001C1.05461 20.0001 1.26654 19.9124 1.42281 19.7561L10.0003 11.1786L18.5778 19.7561C18.7341 19.9124 18.946 20.0001 19.167 20.0001C19.3879 20.0001 19.5999 19.9124 19.7561 19.7561C19.9124 19.5999 20.0001 19.3879 20.0001 19.167C20.0001 18.946 19.9124 18.7341 19.7561 18.5778L11.1786 10.0003L19.7561 1.42281C19.9124 1.26654 20.0001 1.05461 20.0001 0.833644C20.0001 0.612674 19.9124 0.40075 19.7561 0.244477Z" fill="#D2D2D2"/></g><defs><clipPath id="clip0_1163_32333"><rect width="20" height="20" fill="white"/></clipPath></defs></svg></button>
<div class="menu_mob-column">
<?php
function render_mobile_product_categories($parent_id = 0, &$counter = 1, &$buttons_html = '', &$contents_html = '', $level = 0)
{
$exclude_term = get_term_by('name', 'Misc', 'product_cat');
$exclude_id = $exclude_term ? $exclude_term->term_id : 0;
$args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'parent' => $parent_id,
'exclude' => array($exclude_id),
'orderby' => 'menu_order',
'order' => 'ASC',
);
$categories = get_terms($args);
foreach ($categories as $category) {
$child_args = array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'parent' => $category->term_id,
);
$children = get_terms($child_args);
$has_children = !empty($children);
$icon = get_field('category_icon', 'product_cat_' . $category->term_id);
$icon_url = $icon ? $icon['url'] : get_template_directory_uri() . '/assets/images/catalog_icon.png';
// Только верхний уровень (level 0) идёт в кнопки
if ($level === 0) {
$buttons_html .= '<button class="menu_mob-menu__button" data-content="' . esc_attr($counter) . '">';
$buttons_html .= '<div class="menu_mob-button-row">';
$buttons_html .= '<img src="' . esc_url($icon_url) . '" alt="">';
$buttons_html .= '<p>' . esc_html($category->name) . '</p>';
$buttons_html .= '</div>';
if ($has_children) {
$buttons_html .= '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.08984 3.04013V6.15513V8.96013C4.08984 9.44013 4.66984 9.68013 5.00984 9.34013L7.59984 6.75013C8.01484 6.33513 8.01484 5.66013 7.59984 5.24513L6.61484 4.26013L5.00984 2.65513C4.66984 2.32013 4.08984 2.56013 4.08984 3.04013Z" fill="#808080"/></svg>';
}
$buttons_html .= '</button>';
}
// Генерируем контент
$contents_html .= '<div class="menu_mob-menu__content" data-content="' . esc_attr($counter) . '">';
if ($has_children) {
// Заголовок + кнопка назад
$contents_html .= '<div class="menu_mob-menu__content-name">';
$contents_html .= '<button class="menu_mob-menu__content-back">';
$contents_html .= '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.8333 9.16683H7.5L10.2417 6.42517C10.3198 6.3477 10.3818 6.25553 10.4241 6.15398C10.4664 6.05244 10.4882 5.94351 10.4882 5.8335C10.4882 5.72349 10.4664 5.61457 10.4241 5.51302C10.3818 5.41147 10.3198 5.31931 10.2417 5.24184C10.0855 5.08663 9.87432 4.99951 9.65417 4.99951C9.43401 4.99951 9.2228 5.08663 9.06667 5.24184L5.49167 8.82517C5.17868 9.13629 5.00186 9.55885 5 10.0002C5.00406 10.4386 5.1807 10.8578 5.49167 11.1668L9.06667 14.7502C9.14437 14.8273 9.2365 14.8884 9.33781 14.9299C9.43912 14.9715 9.54762 14.9927 9.65711 14.9923C9.76661 14.9919 9.87496 14.97 9.97597 14.9277C10.077 14.8854 10.1687 14.8237 10.2458 14.746C10.323 14.6683 10.3841 14.5762 10.4256 14.4749C10.4672 14.3735 10.4883 14.265 10.488 14.1555C10.4876 14.0461 10.4656 13.9377 10.4234 13.8367C10.3811 13.7357 10.3194 13.644 10.2417 13.5668L7.5 10.8335H15.8333C16.0543 10.8335 16.2663 10.7457 16.4226 10.5894C16.5789 10.4331 16.6667 10.2212 16.6667 10.0002C16.6667 9.77915 16.5789 9.56719 16.4226 9.41091C16.2663 9.25463 16.0543 9.16683 15.8333 9.16683Z" fill="#374957"></path></svg>';
$contents_html .= '</button>';
$contents_html .= '<h4>' . esc_html($category->name) . '</h4>';
$contents_html .= '</div>';
// Кнопки подкатегорий
foreach ($children as $child) {
$sub_children = get_terms([
'taxonomy' => 'product_cat',
'hide_empty' => false,
'parent' => $child->term_id
]);
$has_sub = !empty($sub_children);
$counter++;
$contents_html .= '<button class="menu_mob-menu__button" data-content="' . esc_attr($counter) . '">';
$contents_html .= '<div class="menu_mob-button-row">';
$contents_html .= '<p>' . esc_html($child->name) . '</p>';
$contents_html .= '</div>';
if ($has_sub) {
$contents_html .= '<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.08984 3.04013V6.15513V8.96013C4.08984 9.44013 4.66984 9.68013 5.00984 9.34013L7.59984 6.75013C8.01484 6.33513 8.01484 5.66013 7.59984 5.24513L6.61484 4.26013L5.00984 2.65513C4.66984 2.32013 4.08984 2.56013 4.08984 3.04013Z" fill="#808080"/></svg>';
}
$contents_html .= '</button>';
// Рекурсивно отрисуем подменю для подкатегорий
render_mobile_product_categories($child->term_id, $counter, $buttons_html, $contents_html, $level + 1);
}
} else {
// Если детей нет — это конечная ссылка
$contents_html .= '<div class="menu_mob-menu__content-name">';
$contents_html .= '<a href="' . esc_url(get_term_link($category)) . '">' . esc_html($category->name) . '</a>';
$contents_html .= '</div>';
}
$contents_html .= '</div>';
}
}
?>
<?php
$buttons_html = '';
$contents_html = '';
$counter = 1; // ← сначала создаём переменную
render_mobile_product_categories(0, $counter, $buttons_html, $contents_html); // потом передаём по ссылке
?>
<div class="menu_mob-menu">
<?= $buttons_html ?>
</div>
<?php
$menu_list = wp_get_nav_menu_items('Мобильное меню');
if ($menu_list) {
echo '<nav><ul>';
foreach ($menu_list as $menu_item) {
$class = '';
if (is_page($menu_item->object_id)) {
$class = ' class="active"';
}
echo '<li><a href="' . esc_url($menu_item->url) . '"' . $class . '>' . esc_html($menu_item->title) . '</a></li>';
}
echo '</ul></nav>';
}
?>
<div class="menu_mob-bottom">
<div class="menu_mob-contacts">
<?php
$phone = get_field('phone', 'option');
if ($phone) {
echo '<a href="tel:' . $phone . '"><svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_3046_6829)"><path d="M7.02375 1.00005C8.04288 1.10743 8.99483 1.55945 9.72218 2.28134C10.4495 3.00323 10.9087 3.95175 11.0237 4.97005M7.02375 3.00005C7.5155 3.09702 7.96675 3.33956 8.31894 3.6962C8.67112 4.05284 8.90797 4.50711 8.99875 5.00005M10.9987 8.46005V9.96005C10.9993 10.0993 10.9708 10.2371 10.915 10.3647C10.8592 10.4923 10.7774 10.6068 10.6748 10.701C10.5722 10.7951 10.451 10.8668 10.3191 10.9114C10.1872 10.956 10.0474 10.9726 9.90875 10.96C8.37016 10.7929 6.89225 10.2671 5.59375 9.42505C4.38566 8.65738 3.36141 7.63313 2.59375 6.42505C1.74873 5.12065 1.22287 3.63555 1.05875 2.09005C1.04625 1.95178 1.06268 1.81243 1.107 1.68086C1.15131 1.54929 1.22253 1.42839 1.31613 1.32586C1.40973 1.22332 1.52365 1.1414 1.65064 1.08531C1.77763 1.02922 1.91492 1.00018 2.05375 1.00005H3.55375C3.7964 0.99766 4.03164 1.08359 4.21563 1.24181C4.39961 1.40004 4.51978 1.61977 4.55375 1.86005C4.61706 2.34008 4.73447 2.81141 4.90375 3.26505C4.97102 3.44401 4.98558 3.63851 4.9457 3.82549C4.90582 4.01247 4.81318 4.1841 4.67875 4.32005L4.04375 4.95505C4.75552 6.20682 5.79197 7.24327 7.04375 7.95505L7.67875 7.32005C7.81469 7.18562 7.98632 7.09297 8.17331 7.0531C8.36029 7.01322 8.55478 7.02778 8.73375 7.09505C9.18738 7.26432 9.65871 7.38174 10.1387 7.44505C10.3816 7.47931 10.6034 7.60165 10.762 7.7888C10.9206 7.97594 11.0048 8.21484 10.9987 8.46005Z" stroke="#808080" stroke-linecap="round" stroke-linejoin="round"/></g><defs><clipPath id="clip0_3046_6829"><rect width="12" height="12" fill="white"/></clipPath></defs></svg>' . $phone . '</a>';
}
?>
<?php
$email = get_field('email', 'option');
if ($email) {
echo '<a href="mailto:' . $email . '"><svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11 3.5L6.515 6.35C6.36064 6.44671 6.18216 6.49801 6 6.49801C5.81784 6.49801 5.63936 6.44671 5.485 6.35L1 3.5M2 2H10C10.5523 2 11 2.44772 11 3V9C11 9.55228 10.5523 10 10 10H2C1.44772 10 1 9.55228 1 9V3C1 2.44772 1.44772 2 2 2Z" stroke="#808080" stroke-linecap="round" stroke-linejoin="round"/></svg>' . $email . '</a>';
}
?>
</div>
<div class="menu_mob-buttons">
<button class="menu_mob-button minicart-open">
<div class="menu_mob-button__icon">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_3046_28938)"><path d="M1.3667 1.36719H2.70003L4.47337 9.64719C4.53842 9.95043 4.70715 10.2215 4.95051 10.4138C5.19387 10.606 5.49664 10.7074 5.8067 10.7005H12.3267C12.6301 10.7 12.9244 10.596 13.1607 10.4057C13.3971 10.2154 13.5615 9.95021 13.6267 9.65385L14.7267 4.70052H3.41337M6.00003 14.0005C6.00003 14.3687 5.70156 14.6672 5.33337 14.6672C4.96518 14.6672 4.6667 14.3687 4.6667 14.0005C4.6667 13.6323 4.96518 13.3339 5.33337 13.3339C5.70156 13.3339 6.00003 13.6323 6.00003 14.0005ZM13.3334 14.0005C13.3334 14.3687 13.0349 14.6672 12.6667 14.6672C12.2985 14.6672 12 14.3687 12 14.0005C12 13.6323 12.2985 13.3339 12.6667 13.3339C13.0349 13.3339 13.3334 13.6323 13.3334 14.0005Z" stroke="#2C3846" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></g><defs><clipPath id="clip0_3046_28938"><rect width="16" height="16" fill="white"/></clipPath></defs></svg>
<span class="header-cart__count"><?php echo WC()->cart->get_cart_contents_count(); ?></span>
</div>
Корзина
</button>
<?php if ( is_user_logged_in() ) : ?>
<a href="/account" class="menu_mob-button"><div class="menu_mob-button__icon"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.99984 8.66667C9.84079 8.66667 11.3332 7.17428 11.3332 5.33333C11.3332 3.49238 9.84079 2 7.99984 2C6.15889 2 4.6665 3.49238 4.6665 5.33333C4.6665 7.17428 6.15889 8.66667 7.99984 8.66667ZM7.99984 8.66667C9.41432 8.66667 10.7709 9.22857 11.7711 10.2288C12.7713 11.229 13.3332 12.5855 13.3332 14M7.99984 8.66667C6.58535 8.66667 5.22879 9.22857 4.2286 10.2288C3.22841 11.229 2.6665 12.5855 2.6665 14" stroke="#2C3846" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg></div>Аккаунт</a>
<?php else : ?>
<a href="/login" class="menu_mob-button"><div class="menu_mob-button__icon"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.99984 8.66667C9.84079 8.66667 11.3332 7.17428 11.3332 5.33333C11.3332 3.49238 9.84079 2 7.99984 2C6.15889 2 4.6665 3.49238 4.6665 5.33333C4.6665 7.17428 6.15889 8.66667 7.99984 8.66667ZM7.99984 8.66667C9.41432 8.66667 10.7709 9.22857 11.7711 10.2288C12.7713 11.229 13.3332 12.5855 13.3332 14M7.99984 8.66667C6.58535 8.66667 5.22879 9.22857 4.2286 10.2288C3.22841 11.229 2.6665 12.5855 2.6665 14" stroke="#2C3846" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/></svg></div>Войти</a>
<?php endif; ?>
</div>
</div>
</div>
<?= $contents_html ?>
</div>