-
- € {{ (order.price * order.quantity).toFixed(2) }}
-
-
{{ $t('ecomm.sconto_applicato') }}
+
€ {{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }}
+
+ (€ {{(order.price * order.quantity).toFixed(2) }})
+
+ {{ $t('ecomm.sconto_applicato', {risparmio: getRisparmio()}) }}
diff --git a/src/css/app.scss b/src/css/app.scss
index 4f3de891..0cb008b9 100755
--- a/src/css/app.scss
+++ b/src/css/app.scss
@@ -263,6 +263,13 @@ h3 {
letter-spacing: .00937em;
}
+.text-subtitle3_short {
+ font-size: 1rem;
+ font-weight: 400;
+ line-height: 1.25rem;
+ letter-spacing: .00937em;
+}
+
.text-3d {
letter-spacing: .00937em;
font-size: 1rem;
diff --git a/src/statics/lang/it.js b/src/statics/lang/it.js
index f8730701..244f5640 100755
--- a/src/statics/lang/it.js
+++ b/src/statics/lang/it.js
@@ -1664,7 +1664,10 @@ const msg_it = {
carrello: 'Carrello',
settings: 'Impostazioni',
qta_in_attesa: '(Ordinati In attesa {qty})',
- sconto_applicato: 'Sconto!',
+ sconto_applicato: 'Risparmi {risparmio} € !',
+ codice: 'Codice',
+ code_o_text_search: 'Inserisci il codice o il testo',
+ code_add_to_cart: 'Aggiungi un codice al carrello',
},
},
diff --git a/src/store/Products.ts b/src/store/Products.ts
index 40d4c16a..c89f301e 100755
--- a/src/store/Products.ts
+++ b/src/store/Products.ts
@@ -42,7 +42,12 @@ export const useProducts = defineStore('Products', {
},
- getProduct: (state: IProductsState) => (code: string): IProduct => {
+ getProductById: (state: IProductsState) => (id: string): IProduct => {
+ const prod = state.products.find((prod: IProduct) => prod._id === id)
+ return prod ? prod : { active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [], price: 0 }
+ },
+
+ getProductByCode: (state: IProductsState) => (code: string): IProduct => {
const prod = state.products.find((prod: IProduct) => prod.code === code)
return prod ? prod : { active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [], price: 0 }
},
@@ -114,7 +119,7 @@ export const useProducts = defineStore('Products', {
if (myord.items) {
for (const item of myord.items) {
if (item.order) {
- if (item.order.idProduct === idproduct) {
+ if ((item.order.idProduct === idproduct) && (item.order.status! < shared_consts.OrderStatus.CHECKOUT_SENT)) {
totalQuantity += item.order.quantity || 0;
}
}
@@ -132,7 +137,8 @@ export const useProducts = defineStore('Products', {
const ris = state.orders.filter((ordercart: IOrderCart) => {
return ordercart.items!.some(item => {
if (item.order)
- return item.order.idProduct === idproduct
+ return (item.order.idProduct === idproduct)
+ && (item.order.status! < shared_consts.OrderStatus.CHECKOUT_SENT)
})
})
// console.log('Ordini ', ris)
@@ -432,6 +438,14 @@ export const useProducts = defineStore('Products', {
if (order.quantity === 0)
order.quantity = 1
+ if (!order.idStorehouse) {
+ if (product.storehouses.length === 1) {
+ order.idStorehouse = product.storehouses[0]._id
+ } else {
+ order.idStorehouse = globalStore.storehouses ? globalStore.storehouses[0]._id : ''
+ }
+ }
+
if (order.idStorehouse) {
neworder = this.createOrderByProduct(product, order)
}
@@ -581,6 +595,38 @@ export const useProducts = defineStore('Products', {
return ris
},
+ async addtoCartBase({ $q, t, code, order, addqty }: { $q: any, t: any, code: string, order: IOrder, addqty: boolean }) {
+ let product = this.getProductByCode(code)
+
+ return this.addToCart({ product, order, addqty }).then((ris) => {
+ let strprod = t('ecomm.prodotto')
+
+ if (order.quantity > 1 || order.quantity === 0)
+ strprod = t('ecomm.prodotti')
+
+ let msg = ''
+ if (ris === null)
+ msg = t('ecomm.error_cart')
+ else {
+
+ if (order.quantity === 0) {
+ msg = t('ecomm.prodotto_tolto')
+ } else {
+ msg = t('ecomm.prod_sul_carrello', { strprod, qty: order.quantity })
+ }
+
+ }
+
+ this.updateQuantityAvailable(product._id)
+
+ if (ris === null || order.quantity === 0)
+ tools.showNotif($q, msg)
+ else
+ tools.showPositiveNotif($q, msg)
+
+ })
+ }
+
},
})
diff --git a/src/views/ecommerce/checkOut/checkOut.scss b/src/views/ecommerce/checkOut/checkOut.scss
index 9df13d3c..4067f7bb 100755
--- a/src/views/ecommerce/checkOut/checkOut.scss
+++ b/src/views/ecommerce/checkOut/checkOut.scss
@@ -3,3 +3,6 @@ $heightBtn: 100%;
.card .product-image {
height: 300px;
}
+.insert{
+ cursor:pointer;
+}
\ No newline at end of file
diff --git a/src/views/ecommerce/checkOut/checkOut.ts b/src/views/ecommerce/checkOut/checkOut.ts
index 0f3fe230..15db645f 100755
--- a/src/views/ecommerce/checkOut/checkOut.ts
+++ b/src/views/ecommerce/checkOut/checkOut.ts
@@ -8,7 +8,7 @@ import { useI18n } from '@/boot/i18n'
import { toolsext } from '@store/Modules/toolsext'
import { useQuasar } from 'quasar'
import { costanti } from '@costanti'
-import { ICart, IOrderCart, IShareWithUs } from '@src/model/Products'
+import { ICart, IOrder, IOrderCart, IShareWithUs } from '@src/model/Products'
import { shared_consts } from '@src/common/shared_vuejs'
@@ -33,7 +33,9 @@ export default defineComponent({
const note = ref('')
const endload = ref(false)
const recOrderCart = ref({})
-
+
+ const search = ref('')
+
const statusnow = computed(() => (): number => {
if (recOrderCart.value) {
return recOrderCart.value.status
@@ -158,9 +160,9 @@ export default defineComponent({
title: t('ecomm.order')
}).onOk(async () => {
const status = shared_consts.OrderStatus.CHECKOUT_SENT
-
+
recOrderCart.value = await productStore.CreateOrdersCart({ cart_id: mycart.value._id, status, note: note.value })
-
+
// statusnow.value = myordercart ? myordercart.status : 0
if (recOrderCart.value.status === status) {
@@ -176,6 +178,17 @@ export default defineComponent({
})
}
+ async function insertArticolo() {
+ let lowerSearchText = search.value.trim();
+
+ const myprod = productStore.getProductByCode(lowerSearchText);
+ if (myprod && myprod.active) {
+ let myorder: IOrder = { quantity: 1, price: 0, TotalPriceProduct: 0 }
+ await productStore.addtoCartBase({ $q, t, code: myprod.code!, order: myorder, addqty: true })
+ search.value = ''
+ load()
+ }
+ }
onMounted(mounted)
@@ -197,6 +210,8 @@ export default defineComponent({
recOrderCart,
mycart,
endload,
+ search,
+ insertArticolo,
}
}
})
diff --git a/src/views/ecommerce/checkOut/checkOut.vue b/src/views/ecommerce/checkOut/checkOut.vue
index 304b4b3f..219369cc 100755
--- a/src/views/ecommerce/checkOut/checkOut.vue
+++ b/src/views/ecommerce/checkOut/checkOut.vue
@@ -55,6 +55,27 @@
{{ $t('ecomm.carrello_vuoto') }}
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/ecommerce/productsList/productsList.vue b/src/views/ecommerce/productsList/productsList.vue
index 9720420f..e6aff2bd 100755
--- a/src/views/ecommerce/productsList/productsList.vue
+++ b/src/views/ecommerce/productsList/productsList.vue
@@ -9,7 +9,7 @@