Corretto incongruenze OrdersCart
This commit is contained in:
@@ -6,18 +6,25 @@ const { ObjectID } = require('mongodb');
|
||||
const Order = require('../models/order');
|
||||
|
||||
class Cart {
|
||||
constructor(order) {
|
||||
this.items = {};
|
||||
if (!!order) {
|
||||
this.idapp = order.idapp || 0;
|
||||
this.items[order._id] = order;
|
||||
this.userId = order.userId || "";
|
||||
}
|
||||
constructor(order, arrorders) {
|
||||
this.modify_at = new Date();
|
||||
|
||||
this.items = {};
|
||||
if (!!order) {
|
||||
this.initializeFromOrder(order);
|
||||
} else if (!!arrorders) {
|
||||
for (const ord of arrorders) {
|
||||
this.items.push(ord)
|
||||
}
|
||||
}
|
||||
this.updatetotals();
|
||||
}
|
||||
|
||||
initializeFromOrder(order) {
|
||||
this.idapp = order.idapp || 0;
|
||||
this.userId = order.userId || "";
|
||||
this.items[order._id] = order;
|
||||
}
|
||||
static constructByCart(cart) {
|
||||
try {
|
||||
const mynewcart = new Cart(null);
|
||||
@@ -117,7 +124,7 @@ class Cart {
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
updatetotals() {
|
||||
|
||||
Reference in New Issue
Block a user