- Aggiornamento template mail (tramite i campi in HTML)
- Aggiornato Carrello
This commit is contained in:
@@ -137,6 +137,10 @@ export const useProducts = defineStore('Products', {
|
||||
return state.orders
|
||||
},
|
||||
|
||||
getNumOrders: (state: IProductsState) => (): number => {
|
||||
return state.orders.length
|
||||
},
|
||||
|
||||
getOrdersCart: (state: IProductsState) => (tipoord: number): IOrderCart[] | undefined => {
|
||||
console.log('state.orders', state.orders)
|
||||
if (tipoord === shared_consts.OrderStat.IN_CORSO.value)
|
||||
@@ -321,7 +325,7 @@ export const useProducts = defineStore('Products', {
|
||||
after_price: product.after_price,
|
||||
quantity: order.quantity,
|
||||
quantitypreordered: order.quantitypreordered,
|
||||
idStorehouse: order.idStorehouse,
|
||||
idStorehouse: order.idStorehouse,
|
||||
}
|
||||
|
||||
return myorder
|
||||
@@ -510,7 +514,9 @@ export const useProducts = defineStore('Products', {
|
||||
subqty: !addqty,
|
||||
order: ordcart,
|
||||
}).then((res: any) => {
|
||||
if (res && res.risult) {
|
||||
if (res && res.msgerr) {
|
||||
return res;
|
||||
} else if (res && res.risult) {
|
||||
order.quantity = res.myord.quantity
|
||||
order.quantitypreordered = res.myord.quantitypreordered
|
||||
}
|
||||
@@ -557,7 +563,7 @@ export const useProducts = defineStore('Products', {
|
||||
}
|
||||
this.updateDataProduct(res)
|
||||
|
||||
return { risult: !!res, myord: res.data.myord }
|
||||
return { risult: !!res, myord: res.data.myord, msgerr: res.data.msgerr }
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error addToCart', error)
|
||||
@@ -583,10 +589,10 @@ export const useProducts = defineStore('Products', {
|
||||
let ris = null
|
||||
|
||||
ris = await Api.SendReq('/cart/' + userStore.my._id, 'POST', { addqty, subqty, order })
|
||||
.then((res) => {
|
||||
.then((res: any) => {
|
||||
this.updateDataProduct(res)
|
||||
|
||||
return { risult: !!res, myord: res.data.myord }
|
||||
return { risult: !!res, myord: res.data.myord, msgerr: res.msgerr }
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('error addSubQtyToItem', error)
|
||||
@@ -690,38 +696,42 @@ export const useProducts = defineStore('Products', {
|
||||
|
||||
return await this.addToCart({ product, order, addqty })
|
||||
.then((ris) => {
|
||||
let strprod = t('ecomm.prodotto')
|
||||
|
||||
let msg = ''
|
||||
console.log('ris', ris)
|
||||
if (ris && ris.myord == null) {
|
||||
msg = t('ecomm.prodotto_tolto')
|
||||
tools.showNotif($q, msg)
|
||||
return
|
||||
}
|
||||
if (ris === null || ris.myord == null) {
|
||||
msg = t('ecomm.error_cart')
|
||||
tools.showNegativeNotif($q, msg)
|
||||
return
|
||||
if (ris && ris.msgerr) {
|
||||
tools.showNegativeNotif($q, ris.msgerr)
|
||||
} else {
|
||||
let strprod = t('ecomm.prodotto')
|
||||
|
||||
let qta = ris.myord.quantity + ris.myord.quantitypreordered
|
||||
if (qta > 1 || qta === 0)
|
||||
strprod = t('ecomm.prodotti')
|
||||
|
||||
if (qta > 0) {
|
||||
msg = t('ecomm.prod_sul_carrello', { strprod, qty: qta })
|
||||
let msg = ''
|
||||
console.log('ris', ris)
|
||||
if (ris && ris.myord == null) {
|
||||
msg = t('ecomm.prodotto_tolto')
|
||||
tools.showNotif($q, msg)
|
||||
return
|
||||
}
|
||||
if (ris === null || ris.myord == null) {
|
||||
msg = t('ecomm.error_cart')
|
||||
tools.showNegativeNotif($q, msg)
|
||||
return
|
||||
} else {
|
||||
|
||||
let qta = ris.myord.quantity + ris.myord.quantitypreordered
|
||||
if (qta > 1 || qta === 0)
|
||||
strprod = t('ecomm.prodotti')
|
||||
|
||||
if (qta > 0) {
|
||||
msg = t('ecomm.prod_sul_carrello', { strprod, qty: qta })
|
||||
}
|
||||
|
||||
}
|
||||
if (ris === null || ris.myord.quantity === 0)
|
||||
tools.showNotif($q, msg)
|
||||
else
|
||||
tools.showPositiveNotif($q, msg)
|
||||
|
||||
|
||||
}
|
||||
|
||||
//updateproduct()
|
||||
|
||||
if (ris === null || ris.myord.quantity === 0)
|
||||
tools.showNotif($q, msg)
|
||||
else
|
||||
tools.showPositiveNotif($q, msg)
|
||||
|
||||
return ris
|
||||
})
|
||||
},
|
||||
@@ -783,7 +793,68 @@ export const useProducts = defineStore('Products', {
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getQtyAvailable(myproduct: IProduct): number {
|
||||
let qty = myproduct.quantityAvailable!
|
||||
return qty
|
||||
},
|
||||
|
||||
getQtyBookableAvailable(myproduct: IProduct): number {
|
||||
let qty = myproduct.bookableAvailableQty!
|
||||
return qty
|
||||
},
|
||||
|
||||
enableSubQty(myorder: IOrder): boolean {
|
||||
let qty = myorder.quantity + myorder.quantitypreordered
|
||||
return qty ? qty > 0 : false
|
||||
},
|
||||
|
||||
enableAddQty(myorder: IOrder, myproduct: IProduct): boolean {
|
||||
const globalStore = useGlobalStore()
|
||||
if (globalStore.site.ecomm && globalStore.site.ecomm.enablePreOrders) {
|
||||
return (this.getQtyBookableAvailable(myproduct) > 0
|
||||
&& (myproduct.maxBookableQty === 0
|
||||
|| (myorder.quantitypreordered + 1 < myproduct.maxBookableQty))
|
||||
)
|
||||
|| (this.getQtyAvailable(myproduct) > 0)
|
||||
&& (myproduct.maxBookableQty === 0
|
||||
|| (myorder.quantity + 1 < myproduct.maxBookableQty))
|
||||
|
||||
} else {
|
||||
return (this.getQtyAvailable(myproduct) > 0)
|
||||
&& (myproduct.maxBookableQty === 0
|
||||
|| (myorder.quantity + 1 < myproduct.maxBookableQty))
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
qtaNextAdd(myorder: IOrder, myproduct: IProduct): number {
|
||||
let step = 1
|
||||
if (this.getQtyAvailable(myproduct) > 0) {
|
||||
if (myorder.quantity === 0)
|
||||
step = myproduct.minBuyQty | 1
|
||||
} else {
|
||||
if (myorder.quantitypreordered === 0)
|
||||
step = myproduct.minBuyQty | 1
|
||||
}
|
||||
|
||||
return step
|
||||
},
|
||||
|
||||
qtaNextSub(myorder: IOrder, myproduct: IProduct) {
|
||||
let step = 1
|
||||
let minqta = myproduct.minBuyQty | 1
|
||||
if (this.getQtyAvailable(myproduct) > 0) {
|
||||
if (myorder.quantity === minqta)
|
||||
step = minqta
|
||||
} else {
|
||||
if (myorder.quantitypreordered === minqta)
|
||||
step = minqta
|
||||
}
|
||||
|
||||
return step
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user