diff --git a/wp-content/themes/cosmopet/modules/shop/CosmopetProduct.php b/wp-content/themes/cosmopet/modules/shop/CosmopetProduct.php index c6b198f..af845f5 100644 --- a/wp-content/themes/cosmopet/modules/shop/CosmopetProduct.php +++ b/wp-content/themes/cosmopet/modules/shop/CosmopetProduct.php @@ -984,14 +984,12 @@ class CosmopetProduct extends TimberProduct { } return $attributes; } - - // TO_DO: переименовать в getPriceWithCurrency - public function getPrice(){ + public function getPriceWithCurrency(){ $price = $this->product->get_price() . ' ' . get_woocommerce_currency_symbol(); return $price; } - public function getRegularPrice(){ + public function getRegularPriceWithCurrency(){ $regular_price = $this->product->get_regular_price() . ' ' . get_woocommerce_currency_symbol(); if ($regular_price != $this->getPrice()){ return $regular_price; diff --git a/wp-content/themes/cosmopet/modules/static-pages/new-front-page/template-new-front-page.php b/wp-content/themes/cosmopet/modules/static-pages/new-front-page/template-new-front-page.php index f4b292e..c1d4aa2 100644 --- a/wp-content/themes/cosmopet/modules/static-pages/new-front-page/template-new-front-page.php +++ b/wp-content/themes/cosmopet/modules/static-pages/new-front-page/template-new-front-page.php @@ -115,9 +115,16 @@ if (function_exists('get_field')) { $context['q_5'] = get_field('q_5', 383); // - - $context['food_list'] = get_field('featured_food'); - $context['treats_list'] = get_field('featured_treats'); + $array_food = array(); + foreach (get_field('featured_food') as $item) { + $array_food[] = Timber::get_post($item['product']); + } + $array_treats = array(); + foreach (get_field('featured_treats') as $item) { + $array_treats[] = Timber::get_post($item['product']); + } + $context['food_list'] = $array_food; + $context['treats_list'] = $array_treats; } try { diff --git a/wp-content/themes/cosmopet/views/_blocks/shop/archive-product-ajaxload.twig b/wp-content/themes/cosmopet/views/_blocks/shop/archive-product-ajaxload.twig index 737e702..3059321 100644 --- a/wp-content/themes/cosmopet/views/_blocks/shop/archive-product-ajaxload.twig +++ b/wp-content/themes/cosmopet/views/_blocks/shop/archive-product-ajaxload.twig @@ -1,8 +1,6 @@ {% for post in posts %} - {% set class = post.getTasteClass %} - {% set section = class ~ ' product-archive-card' %} - {% include 'shop/product-card.twig' with {_product : fn('wc_get_product', post.id), section: section} %} + {% include 'woocommerce/product-card.twig' with {item : post, addClass: 'product-archive-card'} %} {% endfor %} diff --git a/wp-content/themes/cosmopet/views/_pages/new-front-page/main-food.twig b/wp-content/themes/cosmopet/views/_pages/new-front-page/main-food.twig index 1a96140..f014f2f 100644 --- a/wp-content/themes/cosmopet/views/_pages/new-front-page/main-food.twig +++ b/wp-content/themes/cosmopet/views/_pages/new-front-page/main-food.twig @@ -2,8 +2,8 @@

сухой гипоаллергенный корм

- {% include 'shop/products-section_block.twig' with {product_list: food_list, section: 'food'} %} - {% include 'shop/reviews-section_block.twig' with { section: 'food', rev_list: reviews_food_query } only %} + {% include 'blocks/modules/shop/products-section.twig' with {product_list: food_list, section: 'food'} %} + {% include 'blocks/modules/shop/reviews-section.twig' with { section: 'food', rev_list: reviews_food_query } only %}
\ No newline at end of file diff --git a/wp-content/themes/cosmopet/views/_pages/new-front-page/main-treats.twig b/wp-content/themes/cosmopet/views/_pages/new-front-page/main-treats.twig index bac9961..4b672cf 100644 --- a/wp-content/themes/cosmopet/views/_pages/new-front-page/main-treats.twig +++ b/wp-content/themes/cosmopet/views/_pages/new-front-page/main-treats.twig @@ -13,8 +13,8 @@
- {% include 'shop/products-section_block.twig' with {product_list: treats_list, section: 'treats'} %} - {% include 'shop/reviews-section_block.twig' with { section: 'treats', rev_list: reviews_treats_query } only %} + {% include 'blocks/modules/shop/products-section.twig' with {product_list: treats_list} %} + {% include 'blocks/modules/shop/reviews-section.twig' with { section: 'treats', rev_list: reviews_treats_query } only %}
\ No newline at end of file diff --git a/wp-content/themes/cosmopet/views/shop/products-section_block.twig b/wp-content/themes/cosmopet/views/blocks/modules/shop/products-section.twig similarity index 74% rename from wp-content/themes/cosmopet/views/shop/products-section_block.twig rename to wp-content/themes/cosmopet/views/blocks/modules/shop/products-section.twig index 085f4bf..6ea5e07 100644 --- a/wp-content/themes/cosmopet/views/shop/products-section_block.twig +++ b/wp-content/themes/cosmopet/views/blocks/modules/shop/products-section.twig @@ -1,6 +1,6 @@
{% for product in product_list %} - {% include 'shop/product-card.twig' with {_product : fn('wc_get_product', product.product)} %} + {% include 'woocommerce/product-card.twig' with {item : product, addClass: ''} %} {% endfor %} {% if section == 'food' %} Вся продукция diff --git a/wp-content/themes/cosmopet/views/shop/reviews-section_block.twig b/wp-content/themes/cosmopet/views/blocks/modules/shop/reviews-section.twig similarity index 100% rename from wp-content/themes/cosmopet/views/shop/reviews-section_block.twig rename to wp-content/themes/cosmopet/views/blocks/modules/shop/reviews-section.twig diff --git a/wp-content/themes/cosmopet/views/shop/product-card.twig b/wp-content/themes/cosmopet/views/shop/product-card.twig deleted file mode 100644 index 0133743..0000000 --- a/wp-content/themes/cosmopet/views/shop/product-card.twig +++ /dev/null @@ -1,84 +0,0 @@ -{# TO_DO: - - 1) в контроллер вынести получение всех переменных, а не тут выхывать функции fn() - 2) переименовать в файл /shop/product-card.twig - 3) _product, wc_product, s_product -- не понятно почему множество переменных с одинаковым смыслом => - надо сделать единый контенкст для всех контроллеров и там создать все нужные переменные - -#} - -{% set thumbnail = _product.get_image_id() ? function('wp_get_attachment_image_url', _product.get_image_id(), 'medium') : function('wc_placeholder_img_src') %} -{% set images = _product.get_gallery_image_ids() %} -{% set compound = fn('wc_get_product_terms', _product.get_id(), 'pa_compound') %} - -
- - -
-
-
- {{_product.get_name()}} -
-
- {% if images %} - {% for image in images %} -
-
- {{ _product.get_title() }} -
-
- {% endfor %} - {% endif %} -
-
-
-
- {% set collection = fn('wc_get_product_terms', _product.id, 'pa_collection') %} - - - {% set cur_weight = function('get_product_info', _product.id, 'weight') %} - - - - - {{_product.get_name()}} - - - {% if collection %} - -
- {% 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 s_product = TimberPost(sibling.ID) %} - {% set wc_product = fn('wc_get_product', sibling.ID) %} - {% set s_in_stock = s_product.meta('_stock_status') == 'instock' %} - {% set s_thumbnail = wc_product.get_image_id() ? function('wp_get_attachment_image_url', wc_product.get_image_id(), 'medium') : function('wc_placeholder_img_src') %} - {% set s_images = wc_product.get_gallery_image_ids() %} - {% set s_title = wc_product.get_title() %} - {% set all_images = [s_thumbnail]|merge(s_images|map(image => function('wp_get_attachment_image_url', image, 'medium'))) %} - {% if s_in_stock %} - {% set class = '' %} - {% if weight == cur_weight %} - {% set class = 'active' %} - {% endif %} - {% if weight %} - - {% endif %} - {% endif %} - {% endfor %} - {% endfor %} -
{% endif %} -
-
{{ _product.get_price() }} {{ fn('get_woocommerce_currency_symbol') }}
- {{ fn('pll_e', 'В корзину') }} -
-
-
\ No newline at end of file diff --git a/wp-content/themes/cosmopet/views/woocommerce/archive-product.twig b/wp-content/themes/cosmopet/views/woocommerce/archive-product.twig index a10d96c..1ca5af9 100644 --- a/wp-content/themes/cosmopet/views/woocommerce/archive-product.twig +++ b/wp-content/themes/cosmopet/views/woocommerce/archive-product.twig @@ -55,15 +55,8 @@ {% if posts|length > 0 %} {% for post in posts %} - - - {% set class = post.getTasteClass %} - {% set section = class ~ ' product-archive-card' %} - - - {% include 'shop/product-card.twig' with {_product : fn('wc_get_product', post.id), section: section} %} - - + + {% include 'woocommerce/product-card.twig' with {item : post, addClass: 'product-archive-card'} %} {% endfor %} {% else %}
diff --git a/wp-content/themes/cosmopet/views/woocommerce/product-card.twig b/wp-content/themes/cosmopet/views/woocommerce/product-card.twig new file mode 100644 index 0000000..f38775d --- /dev/null +++ b/wp-content/themes/cosmopet/views/woocommerce/product-card.twig @@ -0,0 +1,56 @@ +{# TO_DO: + + 1) в контроллер вынести получение всех переменных, а не тут выхывать функции fn() + 2) переименовать в файл /shop/product-card.twig + 3) _product, wc_product, s_product -- не понятно почему множество переменных с одинаковым смыслом => + надо сделать единый контенкст для всех контроллеров и там создать все нужные переменные + +#} + +
+ +
+ {% set image_list = item.getImageGallery('medium') %} + {% if image_list %} + {% for image in image_list %} +
+
+ {{ image.alt }} +
+
+ {% endfor %} + {% endif %} +
+
+
+
+ + + + {{item.title}} + + + {% set size_siblings = post.getSizeSiblings %} + {% if size_siblings %} +
+ + {% for sibling in size_siblings %} + {% set class = '' %} + {% if sibling.get_weight == item.get_weight %} + {% set class = 'active' %} + {% endif %} + {% if sibling.get_weight %} + + {% endif %} + + {% endfor %} +
{% endif %} +
+
{{item.getPriceWithCurrency}}
+ {{ fn('pll_e', 'В корзину') }} +
+
+
\ No newline at end of file diff --git a/wp-content/themes/cosmopet/views/woocommerce/single-product.twig b/wp-content/themes/cosmopet/views/woocommerce/single-product.twig index da7da35..3198c45 100644 --- a/wp-content/themes/cosmopet/views/woocommerce/single-product.twig +++ b/wp-content/themes/cosmopet/views/woocommerce/single-product.twig @@ -229,11 +229,11 @@
- {{post.getPrice}} + {{post.getPriceWithCurrency}}
{% if post.getRegularPrice %}
-
{{post.getRegularPrice}}
+
{{post.getRegularPriceWithCurrency}}
{{ post.getPriceDifferenceInPercent }}
@@ -299,15 +299,8 @@
{% for related_product in post.getRelatedProducts %} - - {% set class = related_product.getTasteClass %} - {% set section = class ~ ' swiper-slide' %} - - - {% include 'shop/product-card.twig' with {_product : fn('wc_get_product', related_product.id), section: section} %} - - - {% endfor %} + {% include 'woocommerce/product-card.twig' with {item : related_product, addClass: 'swiper-slide'} %} + {% endfor %}