- aggiornato carrello e bottoni sul catalogo

This commit is contained in:
Surya Paolo
2025-06-12 10:08:07 +02:00
parent d99ad47483
commit 2dac04fb16
36 changed files with 707 additions and 745 deletions

View File

@@ -61,7 +61,7 @@ function getRecordOrdersCartEmpty(): IOrderCart {
ricevuto: false,
note: '',
note_per_gestore: '',
codice_sconto:'',
codice_sconto: '',
descr_sconto: '',
note_per_admin: '',
note_ordine_gas: '',
@@ -1518,14 +1518,10 @@ export const useProducts = defineStore('Products', {
let ris = null;
ris = await Api.SendReq(
'/cart/' + this.userActive._id + '/app_sc',
'POST',
{
cart_id,
code: codice_sconto,
}
)
ris = await Api.SendReq('/cart/' + this.userActive._id + '/app_sc', 'POST', {
cart_id,
code: codice_sconto,
})
.then((res) => {
this.updateDataProduct(res);
@@ -1545,7 +1541,6 @@ export const useProducts = defineStore('Products', {
return ris;
},
async addtoCartBase({
$q,
t,
@@ -1690,11 +1685,12 @@ export const useProducts = defineStore('Products', {
},
enableSubQty(myorder: IOrder): boolean {
let qty = myorder.quantity + myorder.quantitypreordered;
let qty = myorder?.quantity + myorder?.quantitypreordered;
return qty ? qty > 0 : false;
},
CanDeleteIfSub(myorder: IOrder): boolean {
if (!myorder) return false;
let qty = myorder.quantity + myorder.quantitypreordered;
qty = qty - this.qtaNextSub(myorder, myorder.product!);
@@ -1702,33 +1698,30 @@ export const useProducts = defineStore('Products', {
},
enableAddQty(myorder: IOrder, myproduct: IProduct): boolean {
if (!myorder) return false;
const globalStore = useGlobalStore();
if (globalStore.site.ecomm && globalStore.site.ecomm.enablePreOrders) {
return (
(this.getQtyBookableAvailable(myproduct) > 0 &&
(myproduct.maxBookableSinglePersQty === 0 ||
myorder.quantitypreordered + 1 < myproduct.maxBookableSinglePersQty)) ||
(this.getQtyAvailable(myproduct) > 0 &&
(myproduct.maxBookableSinglePersQty === 0 ||
!myproduct.maxBookableSinglePersQty ||
myorder.quantity + 1 < myproduct.maxBookableSinglePersQty))
);
} else {
return (
this.getQtyAvailable(myproduct) > 0 &&
(myproduct.maxBookableSinglePersQty === 0 ||
!myproduct.maxBookableSinglePersQty ||
myorder.quantity + 1 < myproduct.maxBookableSinglePersQty)
);
}
const maxAllowed = myproduct.maxBookableSinglePersQty || 0;
const qtyAvailable = this.getQtyAvailable(myproduct);
const qtyBookableAvailable = this.getQtyBookableAvailable(myproduct);
const canOrder =
qtyAvailable > 0 &&
((myorder.quantity + 1 <= maxAllowed && maxAllowed > 0) || maxAllowed === 0);
const canPreOrder =
globalStore.site.ecomm?.enablePreOrders &&
qtyBookableAvailable > 0 &&
myorder.quantitypreordered + 1 <= maxAllowed;
return canOrder || canPreOrder;
},
qtaNextAdd(myorder: IOrder, myproduct: IProduct): number {
let step = myproduct.minStepQty || 1;
if (this.getQtyAvailable(myproduct) > 0) {
if (myorder.quantity === 0) step = myproduct.minBuyQty;
if (myorder?.quantity === 0) step = myproduct.minBuyQty;
} else {
if (myorder.quantitypreordered === 0) step = myproduct.minBuyQty;
if (myorder?.quantitypreordered === 0) step = myproduct.minBuyQty;
}
if (step === 0) {
@@ -1742,9 +1735,9 @@ export const useProducts = defineStore('Products', {
let step = myproduct.minStepQty;
let minqta = myproduct.minBuyQty;
if (this.getQtyAvailable(myproduct) > 0) {
if (myorder.quantity === minqta) step = minqta;
if (myorder?.quantity === minqta) step = minqta;
} else {
if (myorder.quantitypreordered === minqta) step = minqta;
if (myorder?.quantitypreordered === minqta) step = minqta;
}
return step;
@@ -2596,8 +2589,9 @@ export const useProducts = defineStore('Products', {
getFilePathByLinkIdTemplate(linkidTemplate: string) {
try {
const globalStore = useGlobalStore();
const myelem = globalStore.myschedas.find((recscheda: IMyScheda) =>
(recscheda: ISchedaSingola) => recscheda.scheda._id === linkidTemplate
const myelem = globalStore.myschedas.find(
(recscheda: IMyScheda) => (recscheda: ISchedaSingola) =>
recscheda.scheda._id === linkidTemplate
);
if (myelem) {
const idPage = myelem.idPageOrig;
@@ -2631,7 +2625,12 @@ export const useProducts = defineStore('Products', {
myorder.idGasordine = '';
},
setMyOrder(myorder: IOrder, myproduct: IProduct, storeSelected: any = null, options: any = {setstore: false}) {
setMyOrder(
myorder: IOrder,
myproduct: IProduct,
storeSelected: any = null,
options: any = { setstore: false }
) {
if (myproduct.storehouses && myproduct.storehouses.length === 1) {
// Se solo 1 presente, metto fisso l'unico negozio !
myorder.idStorehouse = myproduct.storehouses[0]._id;
@@ -2653,8 +2652,6 @@ export const useProducts = defineStore('Products', {
storeSelected = ord.idStorehouse;
}
}
}
},
},
});