You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
cosmopet-architecture/wp-content/themes/cosmopet/woocommerce/archive-product.php

76 lines
3.2 KiB

<?php
wp_enqueue_script( 'shop_scripts', get_template_directory_uri() . '/woocommerce/assets/js/gp-main.js', 'jquery', '', true);
wp_enqueue_style( 'shop_styles_core', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-core.css');
wp_enqueue_style( 'shop_styles_desktop', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-desktop.css');
wp_enqueue_style( 'shop_styles_mobile', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-mobile.css');
wp_enqueue_style( 'shop_styles_tablet', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-tablet.css');
wp_enqueue_style( 'shop_styles_order', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-order.css');
wp_enqueue_style( 'shop_styles_ultra', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-ultra.css');
$context = Timber::context();
//$context['posts'] = Timber::get_posts();
$context['criteria_for_new_product'] = date('Y-m-d', strtotime('-30 days'));
// Задаем количество постов для подзагрузки Ajax
$context['posts_per_page'] = 1;
$queried_object = get_queried_object();
if (is_product_category() || is_tax()) {
$term_id = $queried_object->term_id;
$context['category_type'] = 'product_cat';
$context['category_id'] = $term_id;
$context['category'] = get_term($term_id, 'product_cat');
$context['category_link'] = get_term_link($term_id, 'product_cat');
$context['category_title'] = single_term_title('', false);
}
if (is_tax()) {
$context['category_type'] = $queried_object->taxonomy;
$context['category'] = get_term($term_id, $context['category_type']);
$context['category_link'] = get_term_link($term_id, $context['category_type']);
$context['category_title'] = single_term_title('', false);
}
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => $context['posts_per_page'],
'paged' => 1,
'has_password' => FALSE
);
$count_args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'has_password' => FALSE
);
if ($context['category_id'] != NULL) {
$categories = [
'tax_query' => array(
array(
'taxonomy' => $context['category_type'],
'terms' => $context['category_id'],
'operator' => 'IN'
),
array(
'taxonomy' => 'product_visibility',
'field' => 'slug',
'terms' => 'exclude-from-catalog',
'operator' => 'NOT IN'
)
)
];
$args = array_merge($args, $categories);
$count_args = array_merge($count_args, $categories);
}
$context['posts'] = Timber::get_posts($args);
$context['count'] = count(Timber::get_posts($count_args));
Timber::render('archive-product/archive-product.twig', $context);
?>