fixed carrello che scompariva...
This commit is contained in:
@@ -52,8 +52,8 @@ module.exports.getCartByUserId = async function (uid, idapp) {
|
||||
|
||||
if (!!mycart) {
|
||||
for (const idkey in mycart.items) {
|
||||
try {
|
||||
// idorder = mycart.items[idkey]._id.toString();
|
||||
try {
|
||||
let idorder = mycart.items[idkey]._id.toString();
|
||||
let myorder = mycart.items[idkey].order;
|
||||
if (!!myorder) {
|
||||
idorder = mycart.items[idkey].order._id.toString();
|
||||
@@ -71,7 +71,7 @@ module.exports.getCartByUserId = async function (uid, idapp) {
|
||||
|
||||
mycart.newitems = []
|
||||
for (let item of mycart.items) {
|
||||
if (item.order && item.order.hasOwnProperty('idapp'))
|
||||
if (item.order && item.order.hasOwnProperty('idapp') && (item.order.quantity > 0 || item.order.quantitypreordered > 0))
|
||||
mycart.newitems.push(item)
|
||||
}
|
||||
mycart.items = [...mycart.newitems]
|
||||
|
||||
@@ -270,6 +270,7 @@ module.exports.getOrdersCartByQuery = async function (query) {
|
||||
try {
|
||||
if (item.order.idProduct) {
|
||||
item.order.idProduct.productInfo = item.order.idProduct.productInfo ? item.order.idProduct.productInfo : { ...item.order.idProduct.idProductInfo };
|
||||
item.order.idProduct.productInfo.unitstr = tools.getUnitsMeasure(item.order.idProduct.productInfo.unit, true);
|
||||
item.order.idProduct.idProductInfo = item.order.idProduct.productInfo ? item.order.idProduct.productInfo._id : '';
|
||||
}
|
||||
item.order.product = { ...item.order.idProduct };
|
||||
@@ -918,6 +919,9 @@ module.exports.getmsgorderTelegram = async function (ordersCart) {
|
||||
if (ord.order.quantitypreordered > 0)
|
||||
qtynum += ord.order.quantitypreordered;
|
||||
|
||||
// if (ord.order.product.productInfo.weight)
|
||||
// qtynum *= ord.order.product.productInfo.weight;
|
||||
|
||||
qtystr += qtynum + ' ' + tools.getUnitsMeasure(ord.order.product.productInfo.unit, true);
|
||||
|
||||
if (ord.order.quantitypreordered > 0)
|
||||
|
||||
@@ -83,6 +83,7 @@ router.post('/:userId', authenticate, async function (req, res, next) {
|
||||
nuovo = true;
|
||||
}
|
||||
|
||||
|
||||
let newCart = CartClass.constructByCart(mycart);
|
||||
// order = await Product.updateProductInOrder(order);
|
||||
if (!nuovo) {
|
||||
|
||||
Reference in New Issue
Block a user