]> _ Git - pmi.git/commitdiff
wait #5788 modif mail commande, revu calcul des prix 10
authorsoufiane <soufiane@cubedesigners.com>
Thu, 27 Jul 2023 12:55:20 +0000 (14:55 +0200)
committersoufiane <soufiane@cubedesigners.com>
Thu, 27 Jul 2023 12:55:20 +0000 (14:55 +0200)
app/Http/Controllers/AjaxController.php
resources/views/components/item-cart-order.blade.php
resources/views/components/item-cart.blade.php

index 1112208068ee67f56d7370d9b50e38979489a3a0..a56811813d1d19cfbc7a8a7e14cbf584eb033dc2 100644 (file)
@@ -292,21 +292,23 @@ class AjaxController extends CubistFrontController
         $index = 0;
         $indexMessage = 0;
         $prices = [];
+
         foreach ($cartData as $id => $_data) {
             $indexMessage++;
             $optionsPrices = Product::optionPrice($id, $cartData_[$index]['ref'], $productsArray, true);
             $basicSellingPrice = $products[$id]['basic_selling_price'];
+            $categoryProduct = $products[$id]['category'];
+            $discount = intval(Client::getDiscount($categoryProduct, Client::getCategory()));
 
             if($basicSellingPrice) {
-                $categoryProduct = $products[$id]['category'];
-                $discount = intval(Client::getDiscount($categoryProduct));
-                $price = ECommerceCommon::priceWithDiscount($basicSellingPrice, $discount);
+                $price = $basicSellingPrice;
 
                 if ($optionsPrices) {
                     $totalOptionPrice = Product::totalOptionPrice($optionsPrices[0], $cartData_[$index]['ref']);
                     $price = intval($price) + $totalOptionPrice;
                 }
-                $prices[] = floatval(($price * $_data));
+                $priceDiscount = ECommerceCommon::priceWithDiscount(floatval($price * $_data), $discount);
+                $prices[] = $priceDiscount;
             }
 
             $data['products'][] = [
@@ -314,13 +316,14 @@ class AjaxController extends CubistFrontController
                 'reference' => $cartData_[$index]['ref'],
                 'name' => $products[$id]['name'],
                 'quantity' => $_data,
-                'price' => $price."€" ?? 0
+                'price' => ECommerceCommon::priceWithDiscount($price, $discount)."€" ?? 0
             ];
 
             $productsMessage[] = 'Référence : ' . $cartData_[$index]['ref'] . "\n";
             $productsMessage[$indexMessage] .= url("/{$products[$id]['slug']}")."\n";
 
             $labelPrice = 'Prix unitaire HT : ';
+            $labelPriceDiscount = 'Prix unitaire HT (avec remise) : ';
 
             if($optionsPrices) {
                 $productsMessage[$indexMessage] .= 'Prix de base : ' . $cartData_[$index]['basic_selling_price'] . "€ HT\n";
@@ -328,9 +331,13 @@ class AjaxController extends CubistFrontController
                     $productsMessage[$indexMessage] .= $v . " (+".array_values($optionsPrices[0])[0][$key]."€ HT)\n";
                 }
                 $labelPrice = 'Prix unitaire HT (avec options) : ';
+                $labelPriceDiscount = 'Prix unitaire HT (avec options et remise) : ';
             }
 
             $productsMessage[$indexMessage] .= $labelPrice.$price . "€ \n";
+            if($discount) {
+                $productsMessage[$indexMessage] .= $labelPriceDiscount.$priceDiscount. "€ \n";
+            }
             $productsMessage[$indexMessage] .= 'Qté : ' . $_data . "\n\n";
             $productsMessage[$indexMessage] .= "----\n\n";
 
index 291feba723b1b204f790f72cabcca9b31c660488..8b06bf3607ad78b6c5ef37ad68563ccceaa77d9b 100644 (file)
@@ -30,7 +30,7 @@
                                         $product['basic_selling_price'] }} € HT</span>
                                     </p>
                                     <p class="no-m">{{ __('Votre prix') }} : <span class="text-navy">{{
-                                        number_format($product['basic_selling_price'] - (($product['basic_selling_price'] * $product['discount']) / 100), 2) }} € HT</span>
+                                        number_format(\App\Models\ECommerceCommon::priceWithDiscount($product['basic_selling_price'], $product['discount']), 2) }} € HT</span>
                                     </p>
                                 @endif
                             @else
@@ -49,7 +49,7 @@
                             @if(floatval($product['price']))
                                 <p class="no-m">
                                     <span class="sm:inline hidden">{{ __('Total HT : ') }}</span>
-                                    {{ number_format($product['price'] * $product['quantity'], 2) }}€ HT
+                                    {{ number_format(\App\Models\ECommerceCommon::priceWithDiscount($product['price'],$product['discount']) * $product['quantity'], 2) }}€ HT
                                 </p>
                             @else
                                 <p class="text-navy">
index 96f3369866d92fa5249d4a6233f9063e8fde8682..79e53b6f2aac729ed0f856f6e20b77555912ac78 100644 (file)
@@ -63,7 +63,7 @@
                 @if($item['total'])
                     <div class="text-right pb-6">
                         <p class="no-m">{{ __('Montant Total') }}</p>
-                        <p class="no-m">{{ $price * $product['quantity'] }}€ HT</p>
+                        <p class="no-m">{{ $item['total'] }}€ HT</p>
                     </div>
                 @endif
             </div>