diff --git a/src/components/CProductCard/CProductCard.ts b/src/components/CProductCard/CProductCard.ts index 95431550..74009690 100755 --- a/src/components/CProductCard/CProductCard.ts +++ b/src/components/CProductCard/CProductCard.ts @@ -118,10 +118,13 @@ export default defineComponent({ } function getnumstore() { - if (myproduct.value.storehouses) - return myproduct.value.storehouses.length - else - return 0 + if (myproduct.value) { + if (myproduct.value.storehouses) + return myproduct.value.storehouses.length + else + return 0 + } + return 0 } function getSingleStorehouse() { @@ -138,10 +141,13 @@ export default defineComponent({ function updateproduct() { myproduct.value = products.getProduct(props.code) + products.updateQuantityAvailable(myproduct.value._id) } function getStorehouses() { - + if (!myproduct.value) + return [] + const myarr: any = [] let ind = 1 myproduct.value.storehouses.forEach((store) => { @@ -165,7 +171,6 @@ export default defineComponent({ } function getQtyAvailable() { - products.updateQuantityAvailable(myproduct.value._id) let qty = myproduct.value.quantityAvailable! return qty } @@ -188,7 +193,7 @@ export default defineComponent({ function load() { updateproduct() - console.log('Load', myproduct.value.name) + // console.log('Load', myproduct.value.name) // console.log('created Cproductcard', code) arrordersCart.value = products.getOrdersCartByIdProduct(myproduct.value._id) @@ -204,7 +209,7 @@ export default defineComponent({ } } - console.log('°°° ENDLOAD °°°') + // console.log('°°° ENDLOAD °°°') endload.value = true } diff --git a/src/components/CProductCard/CProductCard.vue b/src/components/CProductCard/CProductCard.vue index 58e7bdb5..71a251e4 100755 --- a/src/components/CProductCard/CProductCard.vue +++ b/src/components/CProductCard/CProductCard.vue @@ -51,7 +51,7 @@ myproduct.after_price }} - + -
+
@@ -92,8 +92,7 @@ > {{ t('products.weight') }}: - + {{ myproduct.weight }} {{ tools.getUnitsMeasure(myproduct.unit, true) }} @@ -102,135 +101,140 @@ - - - - - +
+ + + + + - - - - {{ t('ecomm.preorders') }} - - - {{ t('ecomm.available') }} - - - - + + - {{ -getQtyAvailable() }} + {{ t('ecomm.preorders') }} - {{ getQtyAvailable() }} + {{ t('ecomm.available') }} - -
- {{ getQtyWarn() }} + + + + + {{ -getQtyAvailable() }} + + + {{ getQtyAvailable() }} + + +
+ {{ getQtyWarn() }} -
- {{ - $t('ecomm.qta_in_attesa', { - qty: myproduct.QuantitaOrdinateInAttesa, - }) - }} +
+ {{ + $t('ecomm.qta_in_attesa', { + qty: myproduct.QuantitaOrdinateInAttesa, + }) + }} +
+ + + + + +
+ + + + + + - - - - - - -
-
-
- - {{ t('products.ritiro_presso') }}: -
-
-
- - -
-
- {{ - getSingleStorehouse() - }}
-
- - - - + +
diff --git a/src/components/CSingleCart/CSingleCart.scss b/src/components/CSingleCart/CSingleCart.scss index 1a458cd4..4f761b1c 100755 --- a/src/components/CSingleCart/CSingleCart.scss +++ b/src/components/CSingleCart/CSingleCart.scss @@ -14,3 +14,8 @@ height: 50px; width: 50px; } + +.ordine_scontato_barrato{ + text-decoration: line-through; + color: gray; +} \ No newline at end of file diff --git a/src/components/CSingleCart/CSingleCart.ts b/src/components/CSingleCart/CSingleCart.ts index a7c4aea2..d0886fbe 100755 --- a/src/components/CSingleCart/CSingleCart.ts +++ b/src/components/CSingleCart/CSingleCart.ts @@ -61,6 +61,14 @@ export default defineComponent({ }) } + function isApplicatoSconto() { + const totalipotetico = order.value.price! * order.value.quantity + if (totalipotetico > order.value.TotalPriceProduct!) { + return true + } + return false + } + function removeFromCard() { products.removeFromCart({ order: order.value }) } @@ -69,6 +77,7 @@ export default defineComponent({ myimgclass, addsubqty, removeFromCard, + isApplicatoSconto, } }, }) diff --git a/src/components/CSingleCart/CSingleCart.vue b/src/components/CSingleCart/CSingleCart.vue index 385eab0c..92081d2a 100755 --- a/src/components/CSingleCart/CSingleCart.vue +++ b/src/components/CSingleCart/CSingleCart.vue @@ -28,7 +28,10 @@
- € {{ (order.price * order.quantity) ? (order.price * order.quantity).toFixed(2) : 0 }} +
+ €  {{ (order.price * order.quantity).toFixed(2) }} +
+ € {{ order.TotalPriceProduct ? order.TotalPriceProduct.toFixed(2) : 0 }}
diff --git a/src/model/Products.ts b/src/model/Products.ts index 0817bdb3..bfcaa892 100755 --- a/src/model/Products.ts +++ b/src/model/Products.ts @@ -17,7 +17,7 @@ export interface IProduct { description?: string, department?: string, category?: string, - price?: number, + price: number, after_price?: string, color?: string, size?: string, @@ -48,7 +48,8 @@ export interface IOrder { idProvider?: string idStorehouse?: string idScontisticas?: string[] - price?: number + price: number + TotalPriceProduct: number after_price?: string color?: string size?: string diff --git a/src/store/Products.ts b/src/store/Products.ts index 004172d9..6a191b58 100755 --- a/src/store/Products.ts +++ b/src/store/Products.ts @@ -44,7 +44,7 @@ export const useProducts = defineStore('Products', { getProduct: (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: [] } + return prod ? prod : { active: false, img: '', code: '', name: '', storehouses: [], scontisticas: [], price: 0 } }, getCart: (state: IProductsState) => (): ICart => { @@ -127,7 +127,7 @@ export const useProducts = defineStore('Products', { }, getOrdersCartByIdProduct: (state: IProductsState) => (idproduct: string): IOrderCart[] | [] => { - console.log('getOrdersCartByIdProduct') + // console.log('getOrdersCartByIdProduct') // console.log('.cart.items', this.cart.items) try { if (state.orders) { @@ -137,7 +137,7 @@ export const useProducts = defineStore('Products', { return item.order.idProduct === idproduct }) }) - console.log('Ordini ', ris) + // console.log('Ordini ', ris) return ris ? ris : [] } } catch (e) { @@ -210,6 +210,7 @@ export const useProducts = defineStore('Products', { idProduct: product._id, idProducer: product.idProducer, status: shared_consts.OrderStatus.IN_CART, + TotalPriceProduct: 0, price: product.price, after_price: product.after_price, color: product.color,