From b2a13a20434c5082be27824e01773e0b8564d6d6 Mon Sep 17 00:00:00 2001 From: Olivier Legat Date: Wed, 15 Mar 2023 10:45:53 +0100 Subject: [PATCH] activate prix barres --- app/Models/Product.php | 12 +++++++++++- resources/views/front/sable/home.blade.php | 10 +++++----- .../front/sable/js/components/FilterComponent.vue | 5 ++--- resources/views/front/sable/product.blade.php | 8 ++++---- .../views/front/sable/sass/fo/base/_common.scss | 3 --- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/app/Models/Product.php b/app/Models/Product.php index 99dc2b74..d806184c 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -207,7 +207,17 @@ class Product extends Model implements Buyable if (isset($this->priceKgTtc)) { $showPrice = $this->priceKgTtc; } else { - $priceKgTtc = $this->attributes['price'] * (1 + ($this->tax->rate / 100)); + $discountedPriceKgTtc = $this->price; + if ($this->promotions->count()) { + $applicablePromotion = $this->promotions->first(); + if ($applicablePromotion->discountType->id == 1) { + $discountedPriceKgTtc = $this->price - $applicablePromotion->discount_value; + } else { + $discountedPriceKgTtc = $this->price - ($this->price * $applicablePromotion->discount_value / 100); + } + } + $priceKgTtc = $discountedPriceKgTtc * (1 + ($this->tax->rate / 100)); + /** * On travaille avec des centimes puis on redivise par 100 pour avoir des unités monetaires * on augmente la précision à 3 digits, l'affichage formate les prix sur 2 décimales diff --git a/resources/views/front/sable/home.blade.php b/resources/views/front/sable/home.blade.php index fcbe088d..8c60d15d 100644 --- a/resources/views/front/sable/home.blade.php +++ b/resources/views/front/sable/home.blade.php @@ -28,12 +28,12 @@ {!! $product->description !!}
- {{-- @if ($product->promotions->count()) - @fmt_currency_without_ttc($product->priceTtc) - @endif --}} -

+

@if ($product->weight_variable) Environ* @endif - @fmt_currency($product->discountedPriceTtc) + @fmt_currency($product->discountedPriceTtc) + @if ($product->promotions->count()) + @fmt_currency_without_ttc($product->priceTtc) + @endif /{{ $product->sell_unit }}

diff --git a/resources/views/front/sable/js/components/FilterComponent.vue b/resources/views/front/sable/js/components/FilterComponent.vue index 810208dd..202e29e1 100644 --- a/resources/views/front/sable/js/components/FilterComponent.vue +++ b/resources/views/front/sable/js/components/FilterComponent.vue @@ -137,10 +137,9 @@
Environ* - {{ currencyFormatter(product.discountedPriceTtc) }} + {{ currencyFormatter(product.discountedPriceTtc) }} + {{ currencyFormatter(product.priceTtc) }} /{{ product.sell_unit }} - -

*Produit vendu au kilo : {{ currencyFormatter(product.priceKgTtc) }} /kg

diff --git a/resources/views/front/sable/product.blade.php b/resources/views/front/sable/product.blade.php index 37b7af21..72f3ac25 100644 --- a/resources/views/front/sable/product.blade.php +++ b/resources/views/front/sable/product.blade.php @@ -41,12 +41,12 @@
- {{-- @if ($product->promotions->count()) - @fmt_currency($product->priceTtc) - @endif --}}

@if ($product->weight_variable) Environ* @endif - @fmt_currency($product->discountedPriceTtc) + @fmt_currency($product->discountedPriceTtc) + @if ($product->promotions->count()) + @fmt_currency($product->priceTtc) + @endif /{{ $product->sell_unit }}

diff --git a/resources/views/front/sable/sass/fo/base/_common.scss b/resources/views/front/sable/sass/fo/base/_common.scss index 9947033b..5b893626 100644 --- a/resources/views/front/sable/sass/fo/base/_common.scss +++ b/resources/views/front/sable/sass/fo/base/_common.scss @@ -133,9 +133,6 @@ img { color: $red; margin-left: 1rem !important; } - .card-price-original { - display: block; - } } }