| Server IP : 104.171.130.249 / Your IP : 216.73.216.146 Web Server : nginx/1.25.5 System : Linux 0dac65491b7e 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/themes/matreshka/ |
Upload File : |
<?php
/*
Template Name: Home
*/
global $post;
get_header();
?>
<main id="primary" class="site-main">
<?php
while ( have_posts() ) : the_post();
// Вы можете использовать контент страницы WordPress здесь, если нужно
// the_content();
endwhile;
?>
<!-- account-section -->
<?php if ( ! is_user_logged_in() ) : ?>
<section>
<div class="container d-md-none">
<div class="account-section">
<h3 class="montserrat-semibold">Создайте аккаунт</h3>
<p class="montserrat-medium text-dark-opacity">чтобы получать персональные предложения и баллы за покупки</p>
<button class="btn btn-red-primary montserrat-bold">
Создать
</button>
<div class="">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/img/catmatreshka.png' ); ?>" alt="smile mobile" class="smile1-mobile" width="100">
</div>
</div>
</div>
</section>
<?php endif; ?>
<!-- section-sale -->
<?php if ( function_exists( 'matreshka_first_order_discount_available' ) && matreshka_first_order_discount_available() ) : ?>
<section>
<div class="container">
<div class="sale">
<div class="container-sale">
<h2 class="montserrat-bold">
Скидка 500 ₽ на первый заказ от 1500 ₽
</h2>
<a href="<?php echo esc_url( wc_get_page_permalink( 'shop' ) ); ?>" class="btn btn-white montserrat-bold d-flex align-items-center" style="color: var(--dark)!important;">
За покупками
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/Cart.svg' ); ?>" alt="К покупкам" width="16" height="16" class="ms-1">
</a>
</div>
</div>
</div>
</section>
<?php endif; ?>
<!-- section-home-info -->
<section>
<div class="container ">
<div class="container-home-info d-none d-md-flex">
<div class="home-info-item montserrat-medium">
<a href="<?php echo esc_url( home_url( '/history/' ) ); ?>">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/img/history.png' ); ?>" alt="history" class="me-2">
<p>История покупок</p>
</a>
</div>
<div class="home-info-item montserrat-medium">
<a href="<?php echo esc_url( home_url( '/promotions/' ) ); ?>">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/img/sales.png' ); ?>" alt="sales" class="me-2">
<p>Акции и скидки</p>
</a>
</div>
<div class="home-info-item montserrat-medium">
<a href="<?php echo esc_url( home_url( '/wishlist/' ) ); ?>">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/img/featured.png' ); ?>" alt="featured" class="me-2">
<p>Избранные товары</p>
</a>
</div>
<div class="home-info-cards">
<div class="home-info-card montserrat-medium">
<p>Общий кешбек</p>
<div class="home-info-buttons">
<button class="btn btn-red-secondary montserrat-medium">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/UndoLeftRound.svg' ); ?>" alt="left icon" >
</button>
<?php $cb_settings = matreshka_cashback_settings(); ?>
<p class="montserrat-bold"><?php echo esc_html( str_replace( '.', ',', $cb_settings['default_percent'] ) ); ?>%</p>
</div>
</div>
<div class="home-info-card montserrat-medium">
<p>Ваши категории кешбека</p>
<div class="home-info-buttons">
<a href="<?php echo esc_url( home_url( '/cashback-categories/' ) ); ?>" class="btn btn-red-secondary montserrat-medium">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/UndoLeftRound.svg' ); ?>" alt="left icon" >
</a>
<?php
$user_cb_cats = is_user_logged_in() ? matreshka_get_user_cashback_categories() : [];
if ( ! empty( $user_cb_cats ) ) :
foreach ( $user_cb_cats as $cat_id ) :
$term = get_term( $cat_id, 'product_cat' );
$pct = $cb_settings['category_percents'][ $cat_id ] ?? $cb_settings['default_percent'];
if ( $term && ! is_wp_error( $term ) ) :
?>
<button class="btn btn-white montserrat-semibold btn-cashback-cat"><?php echo esc_html( str_replace('.', ',', $pct) . '% - ' . $term->name ); ?></button>
<?php endif; endforeach; else : ?>
<a href="<?php echo esc_url( home_url( '/cashback-categories/' ) ); ?>" class="btn btn-red-primary montserrat-bold">Выбрать кешбек</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- section-banner -->
<section>
<div class="container">
<div class="container-banner">
<div class="banner-slider">
<?php
// Оптимизированный вывод баннеров через get_posts (сортировка по приоритету)
$banner_ids = get_posts(array(
'post_type' => 'banner',
'numberposts' => 10,
'post_status' => 'publish',
'meta_key' => 'banner_priority',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'fields' => 'ids',
'no_found_rows' => true,
'update_post_term_cache' => false,
'suppress_filters' => true,
));
if ( ! empty( $banner_ids ) ) :
foreach ( $banner_ids as $banner_id ) :
$link = function_exists('get_field') ? get_field('banner_link', $banner_id ) : '';
$thumb = get_the_post_thumbnail_url( $banner_id, 'matreshka_banner' );
if ( ! $thumb ) {
$thumb = get_template_directory_uri() . '/assets/img/banner.png';
}
$title = get_the_title( $banner_id );
?>
<div class="banner-slide mx-2">
<?php if ( $link ) : ?><a href="<?php echo esc_url( $link ); ?>"><?php endif; ?>
<img src="<?php echo esc_url( $thumb ); ?>" alt="<?php echo esc_attr( $title ); ?>" class="img-fluid">
<?php if ( $link ) : ?></a><?php endif; ?>
</div>
<?php
endforeach;
else :
?>
<div class="banner-slide mx-2">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/img/banner.png' ); ?>" alt="banner" class="img-fluid">
</div>
<?php endif; ?>
</div>
</div>
</div>
</section>
<!-- section-current discounts -->
<?php
$active_promos = matreshka_get_active_promotions( 10 );
if ( ! empty( $active_promos ) ) :
?>
<section>
<div class="container">
<div class="container-current-discounts">
<h2 class="montserrat-bold">
<a href="<?php echo esc_url( get_post_type_archive_link( 'promotion' ) ); ?>">
Успейте поучаствовать
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/AltArrowRight.svg' ); ?>" alt="arrow icon" class="current-discounts-arrow">
</a>
</h2>
<div class="current-discounts-list discounts-slider">
<?php foreach ( $active_promos as $promo ) :
$promo_id = $promo->ID;
$promo_link = matreshka_get_promo_link( $promo_id );
$promo_thumb = get_the_post_thumbnail_url( $promo_id, 'medium_large' );
$promo_end = get_post_meta( $promo_id, '_promo_date_end', true );
$badge_text = get_post_meta( $promo_id, '_promo_badge_text', true );
$badge_color = get_post_meta( $promo_id, '_promo_badge_color', true ) ?: '#A92231';
$short_desc = get_post_meta( $promo_id, '_promo_short_description', true );
$days_left = matreshka_promo_days_left( $promo_end );
$date_label = matreshka_promo_date_label( $promo_end );
if ( ! $promo_thumb ) {
$promo_thumb = get_template_directory_uri() . '/assets/img/discounts.png';
}
?>
<div class="current-discounts-item discounts-slide mx-1">
<a href="<?php echo esc_url( $promo_link ); ?>">
<img src="<?php echo esc_url( $promo_thumb ); ?>" alt="<?php echo esc_attr( get_the_title( $promo_id ) ); ?>">
<?php if ( $badge_text ) : ?>
<span class="promo-badge montserrat-bold" style="background-color:<?php echo esc_attr( $badge_color ); ?>;"><?php echo esc_html( $badge_text ); ?></span>
<?php endif; ?>
<?php if ( $days_left <= 3 && $days_left > 0 ) : ?>
<span class="promo-badge-urgent montserrat-bold">🔥 <?php echo $days_left; ?> дн.</span>
<?php endif; ?>
<div class="discounts-title montserrat-medium">
<span class="text-dark-opacity"><?php echo esc_html( $date_label ); ?></span><br/>
<?php echo esc_html( $short_desc ?: get_the_title( $promo_id ) ); ?>
</div>
</a>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</section>
<?php endif; ?>
<!-- section-interesting -->
<section>
<div class="container mb-5">
<div class="container-interesting">
<h2 class="montserrat-bold">
Что интересного
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/AltArrowRight.svg' ); ?>" alt="fire icon">
</h2>
<div class="product-cards container-products">
<?php
// Get featured or random products
$args = array(
'post_type' => 'product',
'posts_per_page' => 10,
'orderby' => 'rand',
);
$featured_products = new WP_Query( $args );
if ( $featured_products->have_posts() ) :
while ( $featured_products->have_posts() ) : $featured_products->the_post();
global $product;
$product_id = get_the_ID();
$product_link = get_permalink();
$product_image = wp_get_attachment_image_url( $product->get_image_id(), 'woocommerce_thumbnail' );
$product_title = get_the_title();
$regular_price = $product->get_regular_price();
$sale_price = $product->get_sale_price();
$weight = $product->get_weight();
$weight_text = $weight ? $weight . 'г' : '200г';
// Check if product is in wishlist
$is_liked = matreshka_is_in_wishlist( $product_id );
$like_icon = $is_liked ? get_template_directory_uri() . '/assets/icons/Heart.svg' : get_template_directory_uri() . '/assets/icons/like.svg';
?>
<div class="product-card" data-product-id="<?php echo esc_attr( $product_id ); ?>">
<a class="link-product" href="<?php echo esc_url( $product_link ); ?>">
<div class="product-card-img">
<?php echo matreshka_get_product_card_image_html( $product, $product_title ); ?>
</div>
<p class="montserrat-medium">
<?php echo esc_html( $product_title ); ?>
</p>
<span class="montserrat-medium"><?php echo esc_html( $weight_text ); ?></span>
</a>
<div class="product-card-bottom">
<?php
// Використовуємо універсальну функцію для відображення ціни
echo matreshka_get_product_price_html( $product );
?>
<img src="<?php echo esc_url( $like_icon ); ?>"
alt="like icon"
class="like-icon <?php echo $is_liked ? 'active' : ''; ?>">
</div>
<button class="btn w-100 btn-secondary montserrat-bold add-to-cart-btn"
data-product_id="<?php echo esc_attr( $product_id ); ?>"
data-product_sku="<?php echo esc_attr( $product->get_sku() ); ?>">
В корзину
</button>
</div>
<?php
endwhile;
wp_reset_postdata();
endif;
?>
</div>
</div>
</div>
</section>
<!-- section-gift-certificates -->
<section>
<div class="container">
<div class="home-gc-banner">
<div class="home-gc-img">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/img/gift-hero.png' ); ?>" alt="Подарочные сертификаты Матрёшка">
</div>
<div class="home-gc-body">
<span class="home-gc-tag montserrat-bold">Подарочные сертификаты</span>
<h2 class="home-gc-title montserrat-bold">Подарите близким радость выбора</h2>
<p class="home-gc-text montserrat-medium">Сертификаты номиналом 3 000, 5 000 и 10 000 ₽ — универсальный подарок для любого повода. Доступны на кассе каждого магазина Матрёшка.</p>
<a href="/podarochnye-sertifikaty/" class="btn btn-red-primary montserrat-bold home-gc-btn">
Узнать подробнее
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/AltArrowRight.svg' ); ?>" alt="arrow" width="16" height="16" style="filter: brightness(0) invert(1); margin-left: 8px;">
</a>
</div>
</div>
</div>
</section>
</main>
<?php
get_footer();