parent
0584522ccf
commit
4e6a703392
@ -0,0 +1,89 @@ |
|||||||
|
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(); |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// Обработка клика на теги активных фильтров
|
||||||
|
document.querySelectorAll('.active-filter-tag').forEach(tag => { |
||||||
|
tag.addEventListener('click', function(e) { |
||||||
|
e.preventDefault(); |
||||||
|
const slug = this.dataset.filterSlug; |
||||||
|
const taxonomy = this.dataset.filterTaxonomy; |
||||||
|
const urlParam = 'wpf_filter_' + taxonomy.replace('pa_', ''); |
||||||
|
|
||||||
|
const url = new URL(window.location.href); |
||||||
|
const params = new URLSearchParams(url.search); |
||||||
|
|
||||||
|
if (params.has(urlParam)) { |
||||||
|
const currentValue = params.get(urlParam); |
||||||
|
|
||||||
|
// Разделяем значения, учитывая как закодированные, так и обычные разделители
|
||||||
|
let values = currentValue.split(/\||%7C|,/); |
||||||
|
|
||||||
|
// Декодируем и фильтруем значения
|
||||||
|
const newValues = values.filter(v => { |
||||||
|
return decodeURIComponent(v.trim()) !== slug.trim(); |
||||||
|
}); |
||||||
|
|
||||||
|
// Обновляем URL параметры
|
||||||
|
if (newValues.length > 0) { |
||||||
|
// Используем | как разделитель (можно заменить на ',', если нужно)
|
||||||
|
params.set(urlParam, newValues.join('|')); |
||||||
|
} else { |
||||||
|
params.delete(urlParam); |
||||||
|
// Дополнительно очищаем связанные параметры
|
||||||
|
if (urlParam.includes('price')) { |
||||||
|
params.delete('wpf_min_price'); |
||||||
|
params.delete('wpf_max_price'); |
||||||
|
} |
||||||
|
params.delete('wpf_fbv'); |
||||||
|
} |
||||||
|
|
||||||
|
// Обновляем URL и перезагружаем страницу
|
||||||
|
url.search = params.toString(); |
||||||
|
window.location.href = url.href; |
||||||
|
} |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// Обработка кнопки "Очистить все"
|
||||||
|
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(); |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
@ -1,9 +0,0 @@ |
|||||||
{% 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 %} |
|
@ -1,128 +0,0 @@ |
|||||||
{% 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> |
|
||||||
{% set stock_status = fn('wc_get_product_stock_status', post.id) %} |
|
||||||
{% if stock_status == 'instock' %} |
|
||||||
<div class="product-item__bye"> |
|
||||||
<button class="button button--white button--100-perc open-overlay"> |
|
||||||
{{ function('pll_e', 'Купить') }} |
|
||||||
</button> |
|
||||||
</div> |
|
||||||
{% else %} |
|
||||||
<button data-pname="{{ post.title }}" class="to-know button--100-perc open-to-know"> |
|
||||||
<p>{{ function('pll_e', 'Узнать о поступлении') }}</p> |
|
||||||
</button> |
|
||||||
{% endif %} |
|
||||||
</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 %} |
|
Loading…
Reference in new issue