From 49ad7596db833792498b984a535614506e2ac48c Mon Sep 17 00:00:00 2001
From: "michael.danielczok" <michael@pcsg.de>
Date: Thu, 4 Jun 2020 16:44:11 +0200
Subject: [PATCH] feat: Show regular and retail price in product list. feat:
 Show shipping time in product list.

---
 bin/css/products.css                          | 72 ++++++++++++++++++-
 locale.xml                                    |  4 ++
 .../Controls/Category/ProductListDetails.html | 32 +++++++--
 .../Controls/Category/ProductListGallery.html | 36 +++++++---
 .../Controls/Category/ProductListList.html    | 21 +++++-
 settings.xml                                  | 12 ++++
 6 files changed, 161 insertions(+), 16 deletions(-)

diff --git a/bin/css/products.css b/bin/css/products.css
index deb7047..1583a7f 100644
--- a/bin/css/products.css
+++ b/bin/css/products.css
@@ -515,11 +515,19 @@
 }
 
 .cologne-products-productGallery-products-product-price {
-    font-weight: bold;
     margin: auto 0 1em;
     text-align: center;
 }
 
+.cologne-products-productGallery-products-product-price-old {
+    font-size: 0.85rem;
+    text-decoration: line-through;
+}
+
+.cologne-products-productGallery-products-product-price-regular {
+    font-weight: bold;
+}
+
 .cologne-products-productGallery-products-product-price .qui-products-price-display {
     display: inline;
 }
@@ -528,6 +536,24 @@
     display: block;
 }
 
+.cologne-products-productGallery-products-product-price-shippingTime {
+    display: flex;
+    margin: auto 0 1em;
+    width: 100%;
+    flex-direction: column;
+    text-align: center;
+}
+
+.cologne-products-productGallery-products-product-price-shippingTime .product-data-fields-title {
+    width: auto;
+    margin-right: 10px;
+}
+
+.cologne-products-productGallery-products-product-price-shippingTime .product-data-fields-value {
+    width: 100%;
+}
+
+
 @media screen and (max-width: 767px) {
     .quiqqer-products-control-product-childrenslider-entry-productButtons {
         width: 100%;
@@ -601,6 +627,14 @@
 }
 
 .cologne-productList-product-details-content-price {
+    margin-top: 1rem;
+}
+
+.cologne-productList-product-details-content-old {
+    text-decoration: line-through;
+    font-size: 0.9rem;
+}
+.cologne-productList-product-details-content-regular {
     font-size: 1.2em;
     font-weight: 500;
 }
@@ -613,6 +647,21 @@
     display: inline;
 }
 
+.cologne-productList-product-details-content-shippingTime {
+    display: flex;
+    margin-top: 1rem;
+    width: 100%;
+}
+
+.cologne-productList-product-details-content-shippingTime .product-data-fields-title {
+    width: auto;
+    margin-right: 10px;
+}
+
+.cologne-productList-product-details-content-stock .product-data-fields-value {
+    width: 100%;
+}
+
 .cologne-productList-product-details-content-buttons {
     border-top: 1px solid #ddd;
     margin-top: 1rem;
@@ -661,6 +710,12 @@
     font-size: 1.2em;
 }
 
+.quiqqer-productList-product-list-price-old {
+    font-weight: normal;
+    font-size: 0.85rem;
+    text-decoration: line-through;
+}
+
 .quiqqer-productList-product-list .quiqqer-productList-product-list-artno,
 .quiqqer-productList-product-list .quiqqer-productList-product-list-price {
     padding: 0 10px;
@@ -670,6 +725,21 @@
     display: inline;
 }
 
+.quiqqer-productList-product-list-text-shippingTime {
+    display: flex;
+    margin-top: 5px;
+    width: 100%;
+}
+
+.quiqqer-productList-product-list-text-shippingTime .product-data-fields-title {
+    width: auto;
+    margin-right: 10px;
+}
+
+.quiqqer-productList-product-list-text-shippingTime .product-data-fields-value {
+    width: 100%;
+}
+
 @media screen and (max-width: 767px) {
     .quiqqer-productList-product-list {
         display: grid;
diff --git a/locale.xml b/locale.xml
index 2b3b6b3..ed74a96 100644
--- a/locale.xml
+++ b/locale.xml
@@ -293,6 +293,10 @@
             <de><![CDATA[Lagerbestand bei Produkt-Details anzeigen]]></de>
             <en><![CDATA[Show stock in product details]]></en>
         </locale>
+        <locale name="settings.shop.categoryShowStock">
+            <de><![CDATA[Lagerbestand in der Produktliste anzeigen]]></de>
+            <en><![CDATA[Show stock in product list]]></en>
+        </locale>
         <locale name="settings.shop.showVisitedProducts">
             <de><![CDATA[Besuchte Produkte auf Produktseite anzeigen]]></de>
             <en><![CDATA[Show visited products on product page.]]></en>
diff --git a/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListDetails.html b/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListDetails.html
index 45d000a..7ace81e 100644
--- a/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListDetails.html
+++ b/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListDetails.html
@@ -19,17 +19,37 @@
         {if !$hidePrice}
         <div class="cologne-productList-product-details-content-price">
             {if $Product->getAttribute('hasVariablePrice')}
-                {locale
-                    group="quiqqer/erp"
-                    var="price.starting.from"
-                    price={control control="QUI\ERP\Products\Controls\Price" Price=$Product->getPrice()}
-                }
+                <div class="cologne-productList-product-details-content-regular">
+                    {locale
+                        group="quiqqer/erp"
+                        var="price.starting.from"
+                        price={control control="QUI\ERP\Products\Controls\Price" Price=$Product->getPrice()}
+                    }
+                </div>
             {else}
-                {$Product->getPriceDisplay()->create()}
+                {assign var=OfferPrice value=$this->getProductOldPriceDisplay($Product)}
+                {if $OfferPrice}
+                <div class="cologne-productList-product-details-content-old">
+                    {$OfferPrice->create()}
+                </div>
+                {/if}
+
+                <div class="cologne-productList-product-details-content-regular">
+                    {$Product->getPriceDisplay()->create()}
+                </div>
             {/if}
         </div>
         {/if}
 
+        {if $Project->getConfig('templateCologne.settings.categoryShowStock')}
+            {assign var=ShippingTimeFrontendView value=\QUI\TemplateCologne\Utils::getShippingTimeFrontendView($Product->getId())}
+            {if $ShippingTimeFrontendView}
+            <div class="cologne-productList-product-details-content-shippingTime">
+                {$ShippingTimeFrontendView->create()}
+            </div>
+            {/if}
+        {/if}
+
         <div class="cologne-productList-product-details-content-buttons">
             <!--<span class="fa fa-envelope button__small quiqqer-products-product-button-purchase"></span>-->
             <!--<span class="fa fa-plus button__small quiqqer-products-product-button-add"></span>-->
diff --git a/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListGallery.html b/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListGallery.html
index c31d1b6..684fa77 100644
--- a/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListGallery.html
+++ b/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListGallery.html
@@ -12,17 +12,37 @@
         {$Product->getTitle()}
     </header>
 
-    <span class="cologne-products-productGallery-products-product-price">
+    <div class="cologne-products-productGallery-products-product-price">
         {if $Product->getAttribute('hasVariablePrice')}
-            {locale
-                group="quiqqer/erp"
-                var="price.starting.from"
-                price={control control="QUI\ERP\Products\Controls\Price" Price=$Product->getPrice()}
-            }
+            <div class="cologne-products-productGallery-products-product-price-regular">
+                {locale
+                    group="quiqqer/erp"
+                    var="price.starting.from"
+                    price={control control="QUI\ERP\Products\Controls\Price" Price=$Product->getPrice()}
+                }
+            </div>
         {else}
-            {$Product->getPriceDisplay()->create()}
+            {assign var=OfferPrice value=$this->getProductOldPriceDisplay($Product)}
+            {if $OfferPrice}
+                <div class="cologne-products-productGallery-products-product-price-old">
+                    {$OfferPrice->create()}
+                </div>
+            {/if}
+
+            <div class="cologne-products-productGallery-products-product-price-regular">
+                {$Product->getPriceDisplay()->create()}
+            </div>
+        {/if}
+    </div>
+
+    {if $Project->getConfig('templateCologne.settings.categoryShowStock')}
+        {assign var=ShippingTimeFrontendView value=\QUI\TemplateCologne\Utils::getShippingTimeFrontendView($Product->getId())}
+        {if $ShippingTimeFrontendView}
+        <div class="cologne-products-productGallery-products-product-price-shippingTime">
+            {$ShippingTimeFrontendView->create()}
+        </div>
         {/if}
-    </span>
+    {/if}
 
     <div class="cologne-products-productGallery-products-product-buttons">
         {template_event name="quiqqer::product-event::slider::buttonAddToCart" Product=$Product}
diff --git a/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListList.html b/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListList.html
index 593135f..6dba1c1 100644
--- a/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListList.html
+++ b/quiqqer/products/src/QUI/ERP/Products/Controls/Category/ProductListList.html
@@ -14,6 +14,15 @@
         <div class="quiqqer-productList-product-list-text-description text-muted">
             {$Product->getDescription()}
         </div>
+
+        {if $Project->getConfig('templateCologne.settings.categoryShowStock')}
+            {assign var=ShippingTimeFrontendView value=\QUI\TemplateCologne\Utils::getShippingTimeFrontendView($Product->getId())}
+            {if $ShippingTimeFrontendView}
+            <div class="quiqqer-productList-product-list-text-shippingTime">
+                {$ShippingTimeFrontendView->create()}
+            </div>
+            {/if}
+        {/if}
     </div>
 
     <div class="quiqqer-productList-product-list-artno">
@@ -52,7 +61,17 @@
                 price={control control="QUI\ERP\Products\Controls\Price" Price=$Product->getPrice()}
             }
         {else}
-            {$Product->getPriceDisplay()->create()}
+
+            {assign var=OfferPrice value=$this->getProductOldPriceDisplay($Product)}
+            {if $OfferPrice}
+            <div class="quiqqer-productList-product-list-price-old">
+                {$OfferPrice->create()}
+            </div>
+            {/if}
+
+            <div class="quiqqer-productList-product-list-price-regular">
+                {$Product->getPriceDisplay()->create()}
+            </div>
         {/if}
     </div>
     {/if}
diff --git a/settings.xml b/settings.xml
index 5f8592f..171df3e 100644
--- a/settings.xml
+++ b/settings.xml
@@ -29,6 +29,10 @@
                         <type><![CDATA[bool]]></type>
                         <defaultvalue>1</defaultvalue>
                     </conf>
+                    <conf name="categoryShowStock">
+                        <type><![CDATA[bool]]></type>
+                        <defaultvalue>0</defaultvalue>
+                    </conf>
                     <conf name="showVisitedProducts">
                         <type><![CDATA[bool]]></type>
                         <defaultvalue>1</defaultvalue>
@@ -299,6 +303,14 @@
                                 </text>
                             </input>
 
+                            <input conf="templateCologne.settings.categoryShowStock" type="checkbox">
+                                <text>
+                                    <locale group="quiqqer/template-cologne"
+                                            var="settings.shop.categoryShowStock"
+                                    />
+                                </text>
+                            </input>
+
                             <input conf="templateCologne.settings.showVisitedProducts" type="checkbox">
                                 <text>
                                     <locale group="quiqqer/template-cologne"
-- 
GitLab