From: soufiane Date: Tue, 6 Jun 2023 16:23:07 +0000 (+0200) Subject: wip #5788 @6:30 correction bug panier/affichage tarif/revoir l'affichage dynamique... X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=52f23c79074e7b61a9584aa7ae70adcc4f4d56f0;p=pmi.git wip #5788 @6:30 correction bug panier/affichage tarif/revoir l'affichage dynamique des tarifs selon le changement de remise, --- diff --git a/app/Http/Controllers/AjaxController.php b/app/Http/Controllers/AjaxController.php index 9f06090..fbd8578 100644 --- a/app/Http/Controllers/AjaxController.php +++ b/app/Http/Controllers/AjaxController.php @@ -149,7 +149,6 @@ class AjaxController extends CubistFrontController public function cart(Request $request) { - $request->validate([ 'action' => 'required|string', // add/update/delete 'id' => 'required|numeric', diff --git a/app/Models/Client.php b/app/Models/Client.php index bd32260..272da88 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -85,7 +85,7 @@ class Client extends CubistMagicAbstractModel $this->addField(['name' => 'discount', 'label' => 'Remise', 'type' => 'select_from_array', - 'options' => ['A','B','C','D','E'], + 'options' => ['A' => 'A','B' => 'B','C' => 'C','D' => 'D','E' => 'E'], 'allows_null' => false, 'default' => 'A', 'column' => true, @@ -107,6 +107,7 @@ class Client extends CubistMagicAbstractModel public static function discountArray($categoryProduct) { $categoryClient = self::getClientConnected()->discount ?? 'A'; + //dd(self::getClientConnected()); $category_array = [ 'A' => 0, 'B' => 5, @@ -125,7 +126,7 @@ class Client extends CubistMagicAbstractModel $discount_array = array_combine($discount_array_save_keys,$discount_array); if($categoryProduct && $categoryClient) { - return $discount_array[$categoryClient][$categoryProduct]; + return $discount_array[$categoryProduct][$categoryClient]; } return null; diff --git a/public/images/icon-angle-down.svg b/public/images/icon-angle-down.svg new file mode 100644 index 0000000..14082e3 --- /dev/null +++ b/public/images/icon-angle-down.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/images/icon-radio-checked.svg b/public/images/icon-radio-checked.svg new file mode 100644 index 0000000..88f96ab --- /dev/null +++ b/public/images/icon-radio-checked.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/public/images/icon-radio.svg b/public/images/icon-radio.svg new file mode 100644 index 0000000..571f7f9 --- /dev/null +++ b/public/images/icon-radio.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/resources/js/app.js b/resources/js/app.js index 2d74912..ad87328 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -96,8 +96,8 @@ const app = new Vue({ mounted() { eventBus.$on('add-item', data => { data.action = 'add'; - data.ref = this.ref ?? data.ref; - data.price = this.price; + data.ref = data.ref !== "" ? data.ref : this.ref; + data.price = data.price !== undefined ? data.price : this.price; this.saveCart(data); }); @@ -162,7 +162,7 @@ const app = new Vue({ priceDiscount() { let discount = this.discount ?? 0 let newValue = (this.price * discount) / 100 - return this.price - newValue.toFixed(2) + return (this.price - newValue).toFixed(2) } }, @@ -648,12 +648,14 @@ $(document).on('click', 'button.cart-add', function () { $(this).find('.add').addClass('hidden'); $(this).find('.added').removeClass('hidden').addClass('inline-flex'); var id = parseInt($(this).attr('data-product-id')), - ref = $(this).attr('data-ref') + ref = $(this).attr('data-ref'), + price = $(this).attr('data-price') eventBus.$emit('add-item', { id: id, quantity: 1, - ref: ref + ref: ref, + price: price }); clearTimeout(time); diff --git a/resources/js/components/CartItem.vue b/resources/js/components/CartItem.vue index e5270b4..ec5b50b 100644 --- a/resources/js/components/CartItem.vue +++ b/resources/js/components/CartItem.vue @@ -6,7 +6,6 @@
- {{ item.ref }} {{ item.reference }}
@@ -16,7 +15,7 @@ Quantité
-
+
{{ Number.parseFloat(price).toFixed(2) }}€ HT
diff --git a/resources/js/product-details.js b/resources/js/product-details.js index e8c7162..47d08e2 100644 --- a/resources/js/product-details.js +++ b/resources/js/product-details.js @@ -1,24 +1,3 @@ -import tippy from 'tippy.js' - -tippy('[data-tooltip]', { - arrow: true, - arrowType: 'sharp', - animation: 'shift-away', - content: function (el) { - return el.getAttribute('data-tooltip'); - }, - flipBehavior: ["top", "bottom"], - theme: 'custom', - placement: 'top', - - popperOptions: { - modifiers: { - data: {styles: {marginBottom: '50px'}}, - hide: {enabled: true} - } - }, -}); - import blueimp from 'blueimp-gallery'; document.getElementById('product-gallery').onclick = function (event) { diff --git a/resources/js/tippy-config.js b/resources/js/tippy-config.js new file mode 100644 index 0000000..76f5aa5 --- /dev/null +++ b/resources/js/tippy-config.js @@ -0,0 +1,20 @@ +import tippy from 'tippy.js' + +tippy('[data-tooltip]', { + arrow: true, + arrowType: 'sharp', + animation: 'shift-away', + content: function (el) { + return el.getAttribute('data-tooltip'); + }, + flipBehavior: ["top", "bottom"], + theme: 'custom', + placement: 'top', + + popperOptions: { + modifiers: { + data: {styles: {marginBottom: '50px'}}, + hide: {enabled: true} + } + }, +}); diff --git a/resources/views/components/cart-add.blade.php b/resources/views/components/cart-add.blade.php index 16e3cc1..c42bce5 100644 --- a/resources/views/components/cart-add.blade.php +++ b/resources/views/components/cart-add.blade.php @@ -14,7 +14,7 @@ @elseif(isset($template) && $template === "miniature" && $options) @else -
@if(floatval($product['price'])) -

{{ $product['price'] * $product['quantity'] }}€ HT

+

{{ number_format($product['price'] * $product['quantity'], 2) }}€ HT

@else

N/A diff --git a/resources/views/pages/paniers_enregistres.blade.php b/resources/views/pages/paniers_enregistres.blade.php index c511e6f..769f991 100644 --- a/resources/views/pages/paniers_enregistres.blade.php +++ b/resources/views/pages/paniers_enregistres.blade.php @@ -1,5 +1,9 @@ @extends('layouts/app') +@push('scripts') + +@endpush + @section('content') diff --git a/resources/views/pages/product-detail.blade.php b/resources/views/pages/product-detail.blade.php index b0ba9d2..1a4d2b0 100644 --- a/resources/views/pages/product-detail.blade.php +++ b/resources/views/pages/product-detail.blade.php @@ -15,6 +15,7 @@ @push('scripts') + @endpush @section('content') @@ -113,7 +114,7 @@ @endauth @if(config('features.quote')) - + ? diff --git a/resources/views/partials/product-link.blade.php b/resources/views/partials/product-link.blade.php index 308f657..f8c3c15 100644 --- a/resources/views/partials/product-link.blade.php +++ b/resources/views/partials/product-link.blade.php @@ -6,7 +6,9 @@ $categoryProduct = $product->category; $discount = \App\Models\Client::discountArray($categoryProduct); - $price = number_format($product->basic_selling_price - (($product->basic_selling_price * $discount) / 100), 2); + $price = floatval(number_format($product->basic_selling_price - (($product->basic_selling_price * $discount) / 100), 2)); + if($price < 1) + $price = "" @endphp

@@ -38,7 +40,7 @@ @endif
@if(config('features.quote')) - + @endif