| 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/template-parts/woocommerce/ |
Upload File : |
<?php
/**
* Template part for displaying shop page
*
* @package Matreshka
*/
?>
<!-- section-home-info -->
<section>
<div class="container">
<div class="d-flex d-md-none ms-3">
<button class="btn btn-white montserrat-medium w-md-100 d-flex d-md-none">
<a href="<?php echo esc_url( home_url( '/my-account/edit-address/billing/' ) ); ?>">
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/Subtract.svg' ); ?>" alt="subtract icon" class="me-2">
<span class="me-md-auto me-2"><?php echo esc_html( matreshka_get_user_address() ); ?></span>
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/AltArrowRight.svg' ); ?>" alt="alt arrow right icon" width="16" height="16" class="me-1">
</a>
</button>
</div>
<div class="container-home-info d-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 d-md-flex d-none">
<?php $cb_settings = matreshka_cashback_settings(); ?>
<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>
<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-categories -->
<section>
<div class="container">
<h2 class="montserrat-semibold shop-title title-category-shop">
Каталог товаров
</h2>
<div class="container-categories">
<?php
// Get all product categories
$product_categories = get_terms( array(
'taxonomy' => 'product_cat',
'hide_empty' => true,
'pad_counts' => true,
'parent' => 0, // Only top-level categories
'exclude' => array(), // Will exclude Misc below
) );
if ( ! empty( $product_categories ) && ! is_wp_error( $product_categories ) ) :
foreach ( $product_categories as $category ) :
// Skip Misc category
if ( $category->slug === 'misc' ) {
continue;
}
$category_link = get_term_link( $category );
// Get category background styles (image and color)
$bg_styles = matreshka_get_category_background_styles( $category->term_id );
?>
<a href="<?php echo esc_url( $category_link ); ?>" class="btn btn-category montserrat-medium"<?php echo $bg_styles['inline_style']; ?>>
<?php echo esc_html( $category->name ); ?>
</a>
<?php
endforeach;
endif;
?>
</div>
</div>
</section>
<?php
// Get products on sale before rendering the section so an empty block is not shown.
$sale_products = new WP_Query( array(
'post_type' => 'product',
'posts_per_page' => 8,
'no_found_rows' => true,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_sale_price',
'value' => 0,
'compare' => '>',
'type' => 'NUMERIC'
),
)
) );
?>
<?php if ( $sale_products->have_posts() ) : ?>
<!-- section-products - Акции -->
<section>
<div class="container mb-md-5 mb-2">
<div class="container-interesting">
<h2 class="montserrat-bold text-red-secondary">
Акции 🔥
</h2>
<div class="product-cards container-products">
<?php
while ( $sale_products->have_posts() ) : $sale_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();
?>
</div>
</div>
</div>
</section>
<?php endif; ?>
<!-- section-categories - подкатегории -->
<?php
// Get all parent categories again to display with their subcategories
if ( ! empty( $product_categories ) && ! is_wp_error( $product_categories ) ) :
foreach ( $product_categories as $parent_category ) :
// Get subcategories for current parent category
$subcategories = get_terms( array(
'taxonomy' => 'product_cat',
'hide_empty' => true,
'pad_counts' => true,
'parent' => $parent_category->term_id,
) );
// Only display section if there are subcategories
if ( ! empty( $subcategories ) && ! is_wp_error( $subcategories ) ) :
$parent_category_link = get_term_link( $parent_category );
?>
<section>
<div class="container">
<a href="<?php echo esc_url( $parent_category_link ); ?>" class="montserrat-semibold shop-title-subcategory mt-4" style="text-decoration: none; color: inherit; display: inline-flex; align-items: center; gap: 8px;">
<?php echo esc_html( $parent_category->name ); ?>
<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/AltArrowRight.svg' ); ?>" alt="arrow right" style="width: 20px; height: 20px;">
</a>
<div class="container-categories cont-subcategories">
<?php
foreach ( $subcategories as $subcategory ) :
// Link to parent category with subcategory filter parameter
$subcategory_link = add_query_arg( 'subcat', $subcategory->term_id, $parent_category_link );
// Get category background styles (image and color)
$bg_styles = matreshka_get_category_background_styles( $subcategory->term_id );
?>
<a href="<?php echo esc_url( $subcategory_link ); ?>" class="btn btn-category montserrat-medium"<?php echo $bg_styles['inline_style']; ?>>
<?php echo esc_html( $subcategory->name ); ?>
</a>
<?php
endforeach;
?>
</div>
</div>
</section>
<?php
endif;
endforeach;
endif;
?>
<!-- section-products - Подобрали для Вас -->
<section>
<div class="container mb-5">
<div class="container-interesting">
<h2 class="montserrat-bold">
Подобрали для Вас
</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-categories - Популярные категории -->
<section>
<div class="container">
<h2 class="montserrat-semibold shop-title title-category-shop">
Популярные категории
</h2>
<div class="container-categories">
<?php
// Show 9 random non-empty product categories.
$popular_categories = get_terms( array(
'taxonomy' => 'product_cat',
'hide_empty' => true,
) );
if ( ! empty( $popular_categories ) && ! is_wp_error( $popular_categories ) ) :
$popular_categories = array_values( array_filter( $popular_categories, function( $category ) {
return $category->slug !== 'misc';
} ) );
shuffle( $popular_categories );
$popular_categories = array_slice( $popular_categories, 0, 9 );
foreach ( $popular_categories as $category ) :
$category_link = get_term_link( $category );
// Get category background styles (image and color)
$bg_styles = matreshka_get_category_background_styles( $category->term_id );
?>
<a href="<?php echo esc_url( $category_link ); ?>" class="btn btn-category montserrat-medium"<?php echo $bg_styles['inline_style']; ?>>
<?php echo esc_html( $category->name ); ?>
</a>
<?php
endforeach;
endif;
?>
</div>
</div>
</section>