From 6dfeb5bc0161c7a985355660beac7a0da33a9650 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 17 May 2025 18:12:43 +0300 Subject: [PATCH] Fix | bugfix --- .../cosmopet/templates/shop/bestsellers.twig | 86 ++++++++++--------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/wp-content/themes/cosmopet/templates/shop/bestsellers.twig b/wp-content/themes/cosmopet/templates/shop/bestsellers.twig index c0b00eb..3b54d11 100644 --- a/wp-content/themes/cosmopet/templates/shop/bestsellers.twig +++ b/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 @@
{% 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 %} - -
-
- - {{ function('pll_e', 'Product image:') }} {{ product.title }} - - -
- - {{ product.title }} + {% 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() %} + +
+
+ + {{ function('pll_e', 'Product image') }}: {{ product.get_name() }} -
-

- {{ price }} {{ currency }} -

- - {% if has_sale %} -
-

- {{ product.regular_price }} {{ currency }} -

-

- -{{ ((1 - (price / product.regular_price)) * 100)|round }}% -

+
+ + {{ product.get_name() }} + + +
+
+ {{ price|raw }}
- {% endif %} + + {% if has_sale and regular_price and sale_price %} +
+

+ {{ regular_price }} {{ currency }} +

+

+ -{{ (1 - (sale_price / regular_price)) * 100|round }}% +

+
+ {% endif %} +
+ + + +
- - - -
-
+ {% endif %} {% endfor %} {% else %}

{{ function('pll_e', 'No bestsellers found') }}