dev_10_refactoring
parent
97ba6b7497
commit
a8c50aa368
@ -0,0 +1,9 @@ |
|||||||
|
{% for post in posts %} |
||||||
|
{% include 'archive-product/archive-product-tease.twig' with {post: post} %} |
||||||
|
{% endfor %} |
||||||
|
|
||||||
|
{% if not ended %} |
||||||
|
<button class="button button--white" id="load-more-products" data-category_id="{{ get_category }}" data-category_type="{{ get_category_type }}"> |
||||||
|
{{ function('pll_e', 'Загрузить еще') }} |
||||||
|
</button> |
||||||
|
{% endif %} |
@ -0,0 +1,121 @@ |
|||||||
|
{% if post.id is defined and post.id %} |
||||||
|
{% set cur_product = fn('wc_get_product', post.id) %} |
||||||
|
{% set attrs = post.product.get_attributes() %} |
||||||
|
{% set cur_weight = function('get_product_info', post.id, 'weight') %} |
||||||
|
|
||||||
|
<div class="product__item"> |
||||||
|
<div class="product-item__label"> |
||||||
|
{% if post.date('Y-m-d') >= criteria_for_new_product %} |
||||||
|
<span class="product-item-label__tag product-item-label__tag--new"> |
||||||
|
{{ function('pll_e', 'Новинка') }} |
||||||
|
</span> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
{% if post._sale_price %} |
||||||
|
<span class="product-item-label__tag product-item-label__tag--sale"> |
||||||
|
{{ function('pll_e', 'Распродажа %') }} |
||||||
|
</span> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
<a href="{{ post.link }}" class="product-item__product-card"> |
||||||
|
<img src="{{ post.thumbnail.src('shop_single') }}" alt="{{ post.title }}" class="product-item__images"> |
||||||
|
</a> |
||||||
|
<div class="product-item__content-card"> |
||||||
|
<div class="compound"> |
||||||
|
{% set compound = fn('wc_get_product_terms', post.id, 'pa_compound') %} |
||||||
|
{% for option in compound %} |
||||||
|
|
||||||
|
{% set term = get_term(option) %} |
||||||
|
<a href="/compound/{{ term.slug }}" class="compound__item">{{ term.name }}</a> |
||||||
|
{% endfor %} |
||||||
|
</div> |
||||||
|
<a href="{{ post.link }}" class="product-item__title">{{ post.title }}</a> |
||||||
|
<div class="product-item__price"> |
||||||
|
<p>{{ post._price() }} {{ fn('get_woocommerce_currency_symbol') }}</p> |
||||||
|
</div> |
||||||
|
<div class="product-item__bye"> |
||||||
|
<button class="button button--white button--100-perc open-overlay"> |
||||||
|
{{ function('pll_e', 'Купить') }} |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="product-item__overlay"> |
||||||
|
<div class="product-item-overlay__header"> |
||||||
|
<a href="{{ post.link }}" class="product-item__title">{{ post.title }}</a> |
||||||
|
|
||||||
|
<ul class="product-item-overlay__tags"> |
||||||
|
{% set features = fn('wc_get_product_terms', post.id, 'pa_features') %} |
||||||
|
{% for option in features %} |
||||||
|
{% set term = get_term(option) %} |
||||||
|
<li>{{ term.name }}</li> |
||||||
|
{% endfor %} |
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
|
||||||
|
<form class="product-item__form" method="post" action="/send-telegram.php"> |
||||||
|
<div class="product-item-overlay__input-block"> |
||||||
|
{% set collection = fn('wc_get_product_terms', post.id, 'pa_collection') %} |
||||||
|
{% if collection %} |
||||||
|
<div class="product-item-overlay__field"> |
||||||
|
<p class="product-item-overlay-field__title">{{ fn('pll_e', 'Объем') }}</p> |
||||||
|
|
||||||
|
<div class="select"> |
||||||
|
<input type="text" class="select__state" value="{{ cur_weight }}" readonly data-product_id="{{post.id}}" data-product_price="{{ post._price() }}"> |
||||||
|
<div class="state__block"> |
||||||
|
<ul class="state__content"> |
||||||
|
|
||||||
|
{% for option in collection %} |
||||||
|
{% set term = get_term(option) %} |
||||||
|
{% set siblings = function('get_collection_siblings' , term.id) %} |
||||||
|
|
||||||
|
{% for sibling in siblings %} |
||||||
|
|
||||||
|
{% set weight = function('get_product_info', sibling.ID, 'weight') %} |
||||||
|
|
||||||
|
{% set class = '' %} |
||||||
|
{% if weight == cur_weight %} |
||||||
|
{% set class = 'active' %} |
||||||
|
{% endif %} |
||||||
|
<li> |
||||||
|
<button class="state__button {{ class }}" data-product_id="{{sibling.ID}}" data-product_price="{{ function('get_product_info', sibling.ID, 'price') }}"> |
||||||
|
{{ weight }} |
||||||
|
</button> |
||||||
|
</li> |
||||||
|
{% endfor %} |
||||||
|
{% endfor %} |
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
<div class="product-item-overlay__field"> |
||||||
|
<p class="product-item-overlay-field__title">{{ fn('pll_e', 'Количество') }}</p> |
||||||
|
|
||||||
|
<div class="counter"> |
||||||
|
<button class="counter__button minus"> |
||||||
|
<img src="{{ theme.link }}/woocommerce/assets/img/svg/main/minus.svg" alt=""> |
||||||
|
</button> |
||||||
|
<input type="text" class="counter__input" value="1"> |
||||||
|
<button class="counter__button plus"> |
||||||
|
<img src="{{ theme.link }}/woocommerce/assets/img/svg/main/plus.svg" alt=""> |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<p class="product-item-overlay__price"> |
||||||
|
{{ post._price() }} |
||||||
|
</p> |
||||||
|
<div class="product-item-overlay__block-button"> |
||||||
|
<div class="product-item-overlay__button"> |
||||||
|
{{ function('get_add_to_cart_button', post.id) }} |
||||||
|
</div> |
||||||
|
<div class="product-item-overlay__more_button"> |
||||||
|
<a class="to-know button--100-perc" href="{{ post.link }}"> |
||||||
|
<p>{{ function('pll_e', 'Подробнее') }}</p> |
||||||
|
</a> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{% endif %} |
@ -0,0 +1,157 @@ |
|||||||
|
{% set bodyClass = 'bg-white' %} |
||||||
|
{% set mainClass = 'wrapper' %} |
||||||
|
{% extends 'layout.twig' %} |
||||||
|
|
||||||
|
{% block content %} |
||||||
|
|
||||||
|
{% if site_region == 'ru' %} |
||||||
|
<style> |
||||||
|
.product-item-overlay__price::after{ |
||||||
|
content: '₽'; |
||||||
|
} |
||||||
|
</style> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
<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="product"> |
||||||
|
<div class="product__header"> |
||||||
|
<h1 class="product__title"> |
||||||
|
{% if category %} |
||||||
|
{{ category.name }} |
||||||
|
{% else %} |
||||||
|
{{ function('pll_e', 'Продукция') }} |
||||||
|
{% endif %} |
||||||
|
</h1> |
||||||
|
|
||||||
|
<button class="button button--gradient button--high button--icon button--filter"> |
||||||
|
{{ function('pll_e', 'Фильтры') }} |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
|
||||||
|
{% if active_filters|length > 0 %} |
||||||
|
<div class="active-filters"> |
||||||
|
{% if active_filters is not empty %} |
||||||
|
<div class="active-filters"> |
||||||
|
{% for filter in active_filters %} |
||||||
|
<span class="active-filter-tag" data-filter-id="{{ filter.id }}" data-filter-slug="{{ filter.slug }}" data-filter-taxonomy="{{ filter.taxonomy }}"> |
||||||
|
{{ filter.name }} × |
||||||
|
</span> |
||||||
|
{% endfor %} |
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
<button class="active-filters__clear button button--white"> |
||||||
|
{{ function('pll_e', 'Очистить все') }} |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
<div class="product__main"> |
||||||
|
{% for post in posts %} |
||||||
|
{% include '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> |
||||||
|
|
||||||
|
<script> |
||||||
|
document.addEventListener("DOMContentLoaded", () => { |
||||||
|
const filterButtons = document.querySelectorAll('.product-tagitem'); |
||||||
|
|
||||||
|
filterButtons.forEach(button => { |
||||||
|
button.addEventListener('click', () => { |
||||||
|
const slug = button.dataset.slug; |
||||||
|
const taxonomy = button.dataset.taxonomy; |
||||||
|
|
||||||
|
const param = 'wpf_filter_' + taxonomy; |
||||||
|
const url = new URL(window.location.href); |
||||||
|
const params = new URLSearchParams(url.search); |
||||||
|
|
||||||
|
if (params.has(param)) { |
||||||
|
let values = params.get(param).split(','); |
||||||
|
values = values.filter(v => v !== slug); |
||||||
|
|
||||||
|
if (values.length > 0) { |
||||||
|
params.set(param, values.join(',')); |
||||||
|
} else { |
||||||
|
params.delete(param); |
||||||
|
} |
||||||
|
|
||||||
|
url.search = params.toString(); |
||||||
|
window.location.href = url.toString(); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// Обработка клика на отдельные теги активных фильтров |
||||||
|
const activeFilterTags = document.querySelectorAll('.active-filter-tag'); |
||||||
|
activeFilterTags.forEach(tag => { |
||||||
|
tag.addEventListener('click', () => { |
||||||
|
const slug = tag.dataset.filterSlug; |
||||||
|
const taxonomy = tag.dataset.filterTaxonomy; |
||||||
|
|
||||||
|
// Убираем префикс pa_ если есть для формирования параметра URL |
||||||
|
const rawTaxonomy = taxonomy.replace('pa_', ''); |
||||||
|
const param = 'wpf_filter_' + rawTaxonomy; |
||||||
|
|
||||||
|
const url = new URL(window.location.href); |
||||||
|
const params = new URLSearchParams(url.search); |
||||||
|
|
||||||
|
if (params.has(param)) { |
||||||
|
let values = params.get(param).split(','); |
||||||
|
values = values.filter(v => v !== slug); |
||||||
|
|
||||||
|
if (values.length > 0) { |
||||||
|
params.set(param, values.join(',')); |
||||||
|
} else { |
||||||
|
params.delete(param); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
url.search = params.toString(); |
||||||
|
window.location.href = url.toString(); |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// Обработка кнопки "Очистить все" |
||||||
|
const clearAllBtn = document.querySelector('.active-filters__clear'); |
||||||
|
if (clearAllBtn) { |
||||||
|
clearAllBtn.addEventListener('click', () => { |
||||||
|
const url = new URL(window.location.href); |
||||||
|
const params = new URLSearchParams(url.search); |
||||||
|
|
||||||
|
for (const key of Array.from(params.keys())) { |
||||||
|
if (key.startsWith('wpf_')) { |
||||||
|
params.delete(key); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
url.search = params.toString(); |
||||||
|
window.location.href = url.toString(); |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
||||||
|
</script> |
||||||
|
|
||||||
|
|
||||||
|
{% endblock %} |
Loading…
Reference in new issue