parent
27e6606835
commit
2a978b3197
@ -1,5 +1,11 @@ |
|||||||
{ |
{ |
||||||
"require": { |
"require": { |
||||||
"timber/timber": "^2.1" |
"timber/timber": "^2.1", |
||||||
|
"mindkomm/timber-integration-woocommerce": "^1.0" |
||||||
|
}, |
||||||
|
"config": { |
||||||
|
"allow-plugins": { |
||||||
|
"composer/installers": true |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,39 +1,75 @@ |
|||||||
<?php |
<?php |
||||||
|
|
||||||
// function get_blog_posts_data() { |
wp_enqueue_script( 'shop_scripts', get_template_directory_uri() . '/woocommerce/assets/js/gp-main.js', 'jquery', '', true); |
||||||
// // $args = array( |
wp_enqueue_style( 'shop_styles_core', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-core.css'); |
||||||
// // 'post_type' => 'post', |
wp_enqueue_style( 'shop_styles_desktop', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-desktop.css'); |
||||||
// // 'posts_per_page' => 6, |
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'); |
||||||
// // $posts = new WP_Query($args); |
wp_enqueue_style( 'shop_styles_ultra', get_template_directory_uri() . '/woocommerce/assets/css/gp-style-ultra.css'); |
||||||
// $formatted_posts = array(); |
|
||||||
|
|
||||||
// if (have_posts()) { |
|
||||||
// while (have_posts()) { |
|
||||||
// the_post(); |
|
||||||
|
|
||||||
// $formatted_post = array( |
|
||||||
// 'title' => get_the_title(), |
|
||||||
// 'link' => get_permalink(), |
|
||||||
// 'excerpt' => get_the_excerpt(), |
|
||||||
// 'thumbnail' => has_post_thumbnail() |
|
||||||
// ? get_the_post_thumbnail_url(get_the_ID(), 'full') |
|
||||||
// : get_template_directory_uri() . "/static/front-page/img/blog_card-img.jpg" |
|
||||||
// ); |
|
||||||
|
|
||||||
// $formatted_posts[] = $formatted_post; |
|
||||||
// } |
|
||||||
// wp_reset_postdata(); |
|
||||||
// } |
|
||||||
|
|
||||||
// return $formatted_posts; |
|
||||||
// } |
|
||||||
|
|
||||||
$context = Timber::get_context(); |
|
||||||
$context['posts'] = Timber::get_posts(); |
|
||||||
|
|
||||||
|
$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); |
Timber::render('archive-product/archive-product.twig', $context); |
||||||
|
|
||||||
|
@ -1,12 +1,72 @@ |
|||||||
{% set bodyClass = 'main-np' %} |
{% set bodyClass = 'bg-white' %} |
||||||
|
{% set mainClass = 'wrapper' %} |
||||||
{% extends 'layout.twig' %} |
{% extends 'layout.twig' %} |
||||||
|
|
||||||
|
|
||||||
{% block content %} |
{% block content %} |
||||||
|
|
||||||
{% for post in posts %} |
{#% do action('woocommerce_before_main_content') %}#} |
||||||
{{ post.title }} |
|
||||||
|
<div class="breadcrumbs"> |
||||||
|
<a href="/" class="breadcrumbs__item"> |
||||||
|
{{ function('pll_e', 'Главная') }} |
||||||
|
</a> |
||||||
|
<a href="/shop" class="breadcrumbs__item"> |
||||||
|
{{ function('pll_e', 'Продукция') }} |
||||||
|
</a> |
||||||
|
{% if category %} |
||||||
|
<a href="{{ category_link }}" class="breadcrumbs__item"> |
||||||
|
{{ category_title }} |
||||||
|
</a> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
|
||||||
|
{#<div class="before-shop-loop""> |
||||||
|
{% do action('woocommerce_before_shop_loop') %} |
||||||
|
</div>#} |
||||||
|
|
||||||
|
<div class="product"> |
||||||
|
<div class="product__header"> |
||||||
|
<p class="product__title"> |
||||||
|
{% if category %} |
||||||
|
{{ category.name }} |
||||||
|
{% else %} |
||||||
|
{{ function('pll_e', 'Продукция') }} |
||||||
|
{% endif %} |
||||||
|
</p> |
||||||
|
|
||||||
|
<button class="button button--gradient button--high button--icon button--filter"> |
||||||
|
{{ function('pll_e', 'Фильтры') }} |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!--<div class="product__tag"> |
||||||
|
<button class="product-tag__item"> |
||||||
|
<div class="product-tag-item__content"> |
||||||
|
<p class="product-tag-item__text">Для собак</p> |
||||||
|
<div class="product-tag-iteИ m__button"> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</button> |
||||||
|
</div>--> |
||||||
|
|
||||||
|
<div class="product__main"> |
||||||
|
{% for post in posts %} |
||||||
|
{% include '/woocommerce/archive-product/archive-product-tease.twig' with {post: post} %} |
||||||
|
{% endfor %} |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="product__footer product__footer--error"> |
||||||
|
{% if posts_per_page < count %} |
||||||
|
<button class="button button--white" id="load-more-products" data-category_id="{{ category_id }}" data-category_type="{{ category_type }}"> |
||||||
|
{{ function('pll_e', 'Загрузить еще') }} |
||||||
|
</button> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
{% endfor %} |
{#{% do action('woocommerce_after_shop_loop') %} |
||||||
|
{% do action('woocommerce_after_main_content') %}#} |
||||||
|
|
||||||
|
{% include '/woocommerce/archive-product/archive-product-modal.twig' %} |
||||||
|
|
||||||
{% endblock %} |
{% endblock %} |
Loading…
Reference in new issue