Fix | bugfix

pull/18/head
Your Name 3 months ago
parent d792206a14
commit 6dfeb5bc01
  1. 42
      wp-content/themes/cosmopet/templates/shop/bestsellers.twig

@ -1,6 +1,4 @@
{#
Bestsellers Slider Template with Polylang support
#}
{# Bestsellers Slider Template with Polylang support #}
{% set best = function('get_field', 'best', 'options') %}
{% set currency = function('get_woocommerce_currency_symbol') %}
@ -24,51 +22,55 @@
<div class="swiper sellerSlider">
<div class="swiper-wrapper">
{% if best %}
{% for product in best %}
{% set product = TimberPost(product) %}
{% set thumbnail = product.thumbnail ? product.thumbnail.src('medium') : function('wc_placeholder_img_src') %}
{% set price = product.price %}
{% set has_sale = product.sale_price and product.sale_price < product.regular_price %}
{% for product_id in best %}
{% set product = function('wc_get_product', product_id) %}
{% if product %}
{% set thumbnail = product.get_image_id() ? function('wp_get_attachment_image_url', product.get_image_id(), 'medium') : function('wc_placeholder_img_src') %}
{% set price = product.get_price_html() %}
{% set has_sale = product.is_on_sale() %}
{% set regular_price = product.get_regular_price() %}
{% set sale_price = product.get_sale_price() %}
<div class="swiper-slide">
<div class="sellers_card">
<a href="{{ product.link }}" aria-label="{{ function('pll_e', 'View product:') }} {{ product.title }}">
<a href="{{ product.get_permalink() }}" aria-label="{{ function('pll_e', 'View product') }}: {{ product.get_name() }}">
<img src="{{ thumbnail }}"
alt="{{ function('pll_e', 'Product image:') }} {{ product.title }}"
alt="{{ function('pll_e', 'Product image') }}: {{ product.get_name() }}"
class="sellers_card-img"
loading="lazy">
</a>
<div class="tags_block">
<a href="{{ product.link }}" class="seller_name">
{{ product.title }}
<a href="{{ product.get_permalink() }}" class="seller_name">
{{ product.get_name() }}
</a>
<div class="seller_bt">
<p class="seller_price">
{{ price }} {{ currency }}
</p>
<div class="seller_price">
{{ price|raw }}
</div>
{% if has_sale %}
{% if has_sale and regular_price and sale_price %}
<div class="product-item__price-disc">
<p class="product-item__price-sale__text">
{{ product.regular_price }} {{ currency }}
{{ regular_price }} {{ currency }}
</p>
<p class="product-item__price-sale__perc">
-{{ ((1 - (price / product.regular_price)) * 100)|round }}%
-{{ (1 - (sale_price / regular_price)) * 100|round }}%
</p>
</div>
{% endif %}
</div>
<a href="{{ product.link }}" class="seller_link">
<button class="seller_buy" aria-label="{{ function('pll_e', 'Buy') }} {{ product.title }}">
<a href="{{ product.get_permalink() }}" class="seller_link">
<button class="seller_buy" aria-label="{{ function('pll_e', 'Buy') }} {{ product.get_name() }}">
{{ function('pll_e', 'Buy') }}
</button>
</a>
</div>
</div>
</div>
{% endif %}
{% endfor %}
{% else %}
<p class="no-products">{{ function('pll_e', 'No bestsellers found') }}</p>

Loading…
Cancel
Save