From: soufiane Date: Tue, 5 Sep 2023 16:40:40 +0000 (+0200) Subject: wip #6245 @1:00 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=c2d89eed2aa5529d44eb4a5f1bf62a3c6f077f96;p=pmi.git wip #6245 @1:00 --- diff --git a/app/Models/ECommerceCommon.php b/app/Models/ECommerceCommon.php index 24aee78..e2aa291 100644 --- a/app/Models/ECommerceCommon.php +++ b/app/Models/ECommerceCommon.php @@ -3,6 +3,7 @@ namespace App\Models; use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel; +use function GuzzleHttp\Psr7\str; class ECommerceCommon extends CubistMagicAbstractModel { @@ -59,6 +60,15 @@ class ECommerceCommon extends CubistMagicAbstractModel return $totalHT * 0.2; } + public static function formatPrice($price) { + $baseFormat = str_replace(",","", $price); + $toFloat = floatval($baseFormat); + $withDecimal = number_format($toFloat,2); + $withoutComma = str_replace(",","",$withDecimal); + $pointToComma = str_replace(".",",", $withoutComma); + return str_replace(" ","",$pointToComma); + } + public static function updateCartData($currentCartRef,$data = [], $productsInfosBase = []) { $opt = []; $total = []; diff --git a/resources/views/components/item-cart.blade.php b/resources/views/components/item-cart.blade.php index 8c63961..c1dc1bf 100644 --- a/resources/views/components/item-cart.blade.php +++ b/resources/views/components/item-cart.blade.php @@ -27,18 +27,18 @@

{{ __('Prix catalogue') }} : @if(floatval($product['price'])) - {{ $product['price'] }} + {{ \App\Models\ECommerceCommon::formatPrice($product['price']) }} @else - {{ $product['basic_selling_price'] }} + {{ \App\Models\ECommerceCommon::formatPrice($product['basic_selling_price']) }} @endif € HT

{{ __('Votre prix') }} : @if(floatval($product['price'])) - {{ $product['price'] - (($product['price'] * $product['discount']) / 100) }} + {{ \App\Models\ECommerceCommon::formatPrice($product['price'] - (($product['price'] * $product['discount']) / 100)) }} @else - {{ number_format($product['basic_selling_price'] - (($product['basic_selling_price'] * $product['discount']) / 100), 2) }} + {{ \App\Models\ECommerceCommon::formatPrice($product['basic_selling_price'] - (($product['basic_selling_price'] * $product['discount']) / 100)) }} @endif € HT

@@ -49,9 +49,9 @@

{{ __('Prix unitaire') }} : @if(floatval($product['price'])) - {{ $product['price'] - (($product['price'] * $product['discount']) / 100) }} + {{ \App\Models\ECommerceCommon::formatPrice($product['price'] - (($product['price'] * $product['discount']) / 100)) }} @else - {{ $product['basic_selling_price'] }} + {{ \App\Models\ECommerceCommon::formatPrice(['basic_selling_price']) }} @endif € HT

@@ -65,7 +65,7 @@ @php($price = $product['price'] - (($product['price'] * $product['discount']) / 100))

- {{ $price * $product['quantity'] }}€ HT + {{ \App\Models\ECommerceCommon::formatPrice($price * $product['quantity']) }}€ HT

@else

@@ -85,9 +85,9 @@ @if($item['total'])

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

-

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

-

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

-

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

+

{{ __('Total HT') }} : {{ \App\Models\ECommerceCommon::formatPrice($prices += ($prices < 1000 ? 20 : 0)) }}€

+

{{ __('Montant TVA') }} : {{ \App\Models\ECommerceCommon::formatPrice($prices * 0.2) }}€

+

{{ __('Total TTC') }} : {{ \App\Models\ECommerceCommon::formatPrice($item['total']) }}€

@endif