From f730fe32a57a881b3c9944f14fbde6c52a72df3d Mon Sep 17 00:00:00 2001 From: soufiane Date: Tue, 5 Sep 2023 18:08:05 +0200 Subject: [PATCH] wait #6244 @1:30 --- app/Models/ECommerceCommon.php | 4 +-- .../components/item-cart-order.blade.php | 30 +++++++++++++++---- .../views/components/item-cart.blade.php | 10 +++++-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/app/Models/ECommerceCommon.php b/app/Models/ECommerceCommon.php index 4e1a86b..24aee78 100644 --- a/app/Models/ECommerceCommon.php +++ b/app/Models/ECommerceCommon.php @@ -47,7 +47,7 @@ class ECommerceCommon extends CubistMagicAbstractModel } public static function totalHT($price, $discount, $quantity) { $t = self::priceWithDiscount($price, $discount) * $quantity; - $t += ($t > 1000) ? 20 : 0; + $t += ($t < 1000) ? 20 : 0; return $t; } @@ -110,7 +110,7 @@ class ECommerceCommon extends CubistMagicAbstractModel }); $ht = array_reduce($total, function($carry, $item) { return $carry + $item; }); - $ht += ($ht > 1000) ? 20 : 0; + $ht += ($ht < 1000) ? 20 : 0; $tva = $ht * 0.2; $ttc = $ht + $tva; $data['total'] = !$unavailableEcommerceProduct ? number_format($ttc,2) : null; diff --git a/resources/views/components/item-cart-order.blade.php b/resources/views/components/item-cart-order.blade.php index b9ec1a0..3d9691e 100644 --- a/resources/views/components/item-cart-order.blade.php +++ b/resources/views/components/item-cart-order.blade.php @@ -1,5 +1,9 @@ @if($items) @foreach($items as $item) + @php + $prices = array_map(function($product){ return ($product['price'] - (($product['price'] * $product['discount']) / 100)) * $product['quantity']; },json_decode($item['products'],true)); + $prices = array_reduce($prices, function($carry, $item) { return $carry += $item; }); + @endphp
@@ -31,8 +35,14 @@

{{ $product['name'] }}

@if(isset($product['discount']) && $product['discount'] !== 0) @if(floatval($product['basic_selling_price'])) -

{{ __('Prix catalogue') }} : {{ - $product['basic_selling_price'] }} € HT +

{{ __('Prix catalogue') }} : + + @if(floatval($product['price'])) + {{ $product['price'] }} + @else + {{ $product['basic_selling_price'] }} + @endif € HT +

{{ __('Votre prix') }} : {{ number_format(\App\Models\ECommerceCommon::priceWithDiscount($product['basic_selling_price'], $product['discount']), 2) }} € HT @@ -41,8 +51,14 @@ @else @isset($product['basic_selling_price']) @if(floatval($product['basic_selling_price'])) -

{{ __('Prix unitaire') }} : {{ - $product['basic_selling_price'] }} € HT +

{{ __('Prix unitaire') }} : + + @if(floatval($product['price'])) + {{ $product['price'] }} + @else + {{ $product['basic_selling_price'] }} + @endif € HT +

@endif @endisset @@ -83,8 +99,10 @@
@if($item['total'])
-

{{ __('Montant Total') }}

-

{{ $item['total'] }}€ TTC

+

{{ __('Frais de port') }} : {{ $prices < 1000 ? 20 : 0 }}€

+

{{ __('Total HT') }} : {{ $prices += ($prices < 1000 ? 20 : 0) }}€

+

{{ __('Montant TVA') }} : {{ $prices * 0.2 }}€

+

{{ __('Total TTC') }} : {{ $item['total'] }}€

@endif
diff --git a/resources/views/components/item-cart.blade.php b/resources/views/components/item-cart.blade.php index 0edf71e..2ba11d4 100644 --- a/resources/views/components/item-cart.blade.php +++ b/resources/views/components/item-cart.blade.php @@ -1,5 +1,9 @@ @if($items) @foreach($items as $item) + @php + $prices = array_map(function($product){ return ($product['price'] - (($product['price'] * $product['discount']) / 100)) * $product['quantity']; },json_decode($item['products'],true)); + $prices = array_reduce($prices, function($carry, $item) { return $carry += $item; }); + @endphp
@@ -80,8 +84,10 @@
@if($item['total'])
-

{{ __('Montant Total') }}

-

{{ $item['total'] }}€ TTC

+

{{ __('Frais de port') }} : {{ $prices < 1000 ? 20 : 0 }}€

+

{{ __('Total HT') }} : {{ $prices += ($prices < 1000 ? 20 : 0) }}€

+

{{ __('Montant TVA') }} : {{ $prices * 0.2 }}€

+

{{ __('Total TTC') }} : {{ $item['total'] }}€

@endif
-- 2.39.5