From 7bae6e14b6862d849a8faf0864e4cf228c882492 Mon Sep 17 00:00:00 2001 From: soufiane Date: Tue, 11 Apr 2023 18:23:19 +0200 Subject: [PATCH] wip #5850 @7:00 --- app/Models/Product.php | 21 ++--- resources/js/app.js | 24 +++++- resources/js/components/CartItem.vue | 4 +- resources/styles/common/spacing.styl | 2 +- resources/styles/components/cart.styl | 50 +++++++++++ resources/views/components/cart-add.blade.php | 2 +- resources/views/pages/cart.blade.php | 84 +++++++++++++++++-- .../views/pages/product-detail.blade.php | 9 +- resources/views/partials/account.blade.php | 5 +- 9 files changed, 169 insertions(+), 32 deletions(-) diff --git a/app/Models/Product.php b/app/Models/Product.php index b00d25c..c5f05f2 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -163,6 +163,12 @@ class Product extends CubistMagicPageModel 'tab' => 'Produits associés', ]); + $this->addField(['name' => 'time_limit', + 'label' => 'Délai', + 'type' => 'Text', + 'tab' => 'Informations fournisseur' + ]); + foreach ($this->_hidden_options as $name => $label) { $this->addField(['name' => $name, 'label' => $label, @@ -476,21 +482,6 @@ class Product extends CubistMagicPageModel if (count($cart_items) > 0) { self::$_cart_data = $cart_items; - //$products = self::with('media')->whereIn('id', array_keys($cart_items))->get(); - - /*foreach ($cart_items as $product) { - self::$_cart_data[] = [ - 'id' => $product['id'], - 'name' => $product['name'], - 'reference' => $product['reference'], - 'category' => $product['category'], - 'quantity' => $product['quantity'], - 'image' => $product['image'], - 'URL' => $product['URL'], - 'price' => $product['price'], - 'ref' => $product['ref'] - ]; - }*/ } } diff --git a/resources/js/app.js b/resources/js/app.js index 6720383..5480aaa 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -112,7 +112,7 @@ const app = new Vue({ }); this.ref = this.$refs.refProduct?.dataset.ref - this.price = this.$refs.optprice ?.dataset.default + this.price = parseFloat(this.$refs.optprice ?.dataset.default).toFixed(2) this.statusText = this.$refs.statusConfig ?.dataset.incomplete }, @@ -133,12 +133,26 @@ const app = new Vue({ }, cartItemHasPriceCount() { - return this.items.length ? this.items.filter(n => n.price !== "").length : 0 + return this.items.length ? this.items.filter(n => n.price !== "" && !isNaN(n.price)).length : 0 }, total() { - let prices = this.items.map(item => item.price * item.quantity) - return this.items.length ? prices.reduce((init, current) => init + current) : false + let prices = this.items.length ? this.items.map(item => item.price * item.quantity) : false + + prices = prices ? Number.parseFloat(prices.reduce((init, current) => init + current)) : 0 + prices += (prices > 1000) ? 20 : 0 + + return prices.toFixed(2) + }, + + tva() { + let tva = this.total ? this.total * 0.2 : 0 + return tva.toFixed(2) + }, + + totalTTC() { + let total = this.total ? parseFloat(this.total) + parseFloat(this.tva) : 0 + return total.toFixed(2) } }, @@ -256,6 +270,7 @@ const app = new Vue({ axios.post('/ajax/check_email_exist', data) .then(function (response) { root.validateEmail = true + root.removeErrorsForm() if (response.data.length > 0) { root.emailExist = true } @@ -453,6 +468,7 @@ const app = new Vue({ this.ref = this.$refs.refProduct.dataset.ref+'/'+placeholder this.price = total + parseFloat(this.$refs.optprice.dataset.default) + this.price = parseFloat(this.price).toFixed(2) } }, /** diff --git a/resources/js/components/CartItem.vue b/resources/js/components/CartItem.vue index dd56867..81a2226 100644 --- a/resources/js/components/CartItem.vue +++ b/resources/js/components/CartItem.vue @@ -16,8 +16,8 @@ Quantité -
- {{ price }}€ HT +
+ {{ Number.parseFloat(price).toFixed(2) }}€ HT
Supprimer diff --git a/resources/styles/common/spacing.styl b/resources/styles/common/spacing.styl index 4ef8a8d..adbeaf8 100644 --- a/resources/styles/common/spacing.styl +++ b/resources/styles/common/spacing.styl @@ -8,7 +8,7 @@ $vw-spacing = { '2': 5vw, '3': 7.5vw, '4': 10vw, - '5': 12.5vw, + '5': 12.5vw } $sides = { diff --git a/resources/styles/components/cart.styl b/resources/styles/components/cart.styl index f8cb1f6..71ed0b5 100644 --- a/resources/styles/components/cart.styl +++ b/resources/styles/components/cart.styl @@ -75,6 +75,56 @@ .cart-quantity @apply bg-white max-width: 220px + .cart-addresses + form + label + padding-left: 20px !important + + [type="radio"] + width: 16px !important + height: 24px + margin: 0 + border: 0 + display: grid + place-content: center + padding: 0 + position: relative + appearance: none + + &:before + content: "" + width: 16px + height: 16px + background-image: url(/images/icon-radio.svg) + background-repeat: no-repeat + background-position: center + &:checked:before + content: "" + background-image: url(/images/icon-radio-checked.svg) + background-repeat: no-repeat + background-position: center + border-radius: 50px + +.cart-shipping-fees + padding: 10px 0 + margin-bottom: 36px + border: 1px solid #D5D7DF + border-left: 0 + border-right: 0 + +.cart-total + p + margin-bottom: 0 !important + +.cart-valid-command + margin: 32px 0 28px + +.cart-links + margin-bottom: 32px + a + display: inline-block + &:not(:last-child) + margin-bottom: 10px // Cart item .cart-item diff --git a/resources/views/components/cart-add.blade.php b/resources/views/components/cart-add.blade.php index ade4c69..386441d 100644 --- a/resources/views/components/cart-add.blade.php +++ b/resources/views/components/cart-add.blade.php @@ -1,4 +1,4 @@ - + + + +
+ En nous transmettant votre demande, vous acceptez que PM Instrumentation traite vos données + personnelles dans le but de vous offrir un service de qualité. Pour plus d’information sur la + protection de vos données à caractère personnel, vous pouvez consulter la page + Vie privée. +
-
+
@form([ 'action' => '/ajax/request_quote', 'ga'=>false, 'extra_fields' => '' // Populated by VueJS ])
+ +
+

{{ __('Choisir une adresse de facturation') }} :

+
+
+
+
+ + +
+
+
+ {{ __('Ajouter une adresse') }} +
+

{{ __('Choisir une adresse de livraison') }} :

+
+
+
+
+ + +
+
+
+ {{ __('Ajouter une adresse') }} +
+
-
+
{{ __("Vous n'avez encore rien sélectionné") }}
diff --git a/resources/views/pages/product-detail.blade.php b/resources/views/pages/product-detail.blade.php index fe523e5..68e53fb 100644 --- a/resources/views/pages/product-detail.blade.php +++ b/resources/views/pages/product-detail.blade.php @@ -73,8 +73,8 @@
-
{{ __('Référence') }} : @{{ ref }}
-
+
{{ __('Référence') }} : @{{ ref }}
+
{{ __('Prix unitaire') }} : @{{ price }}{{ "€ ".__('HT') }}
@@ -94,6 +94,11 @@ class="font-display text-lg inline-block align-middle rounded-full border-grey-dark border-2 h-8 w-8 text-center ml-6">? @endif + @isset($product->time_limit) +
+ {{ $product->time_limit }} +
+ @endisset
diff --git a/resources/views/partials/account.blade.php b/resources/views/partials/account.blade.php index 02ef123..510b857 100644 --- a/resources/views/partials/account.blade.php +++ b/resources/views/partials/account.blade.php @@ -1,9 +1,10 @@