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

Loading…
Cancel
Save