Aggiungi il codice alla cassa in automatico

This commit is contained in:
Surya Paolo
2023-12-18 15:21:07 +01:00
parent a3913a4575
commit 7e7d7ca6b4
2 changed files with 17 additions and 1 deletions

View File

@@ -244,6 +244,10 @@ module.exports.updateStatusOrdersElements = async function (arrOrders, myelement
module.exports.updateTotals = function (order) {
try {
if (!order) {
return;
}
let mypricecalc = 0;
order.TotalPriceProduct = 0;

View File

@@ -57,8 +57,12 @@ router.post('/:userId', authenticate, async function (req, res, next) {
try {
let mycart = await Cart.getCartByUserId(userId, idapp);
if (!order) {
return res.send({ code: server_constants.RIS_CODE_OK, cart: null });
}
// const myorder = Order.getOrderByID(order._id);
if (!addqty && !subqty) {
if (!addqty && !subqty && order) {
order._id = await Order.createOrder(order);
if (!order._id) {
return res.send({ code: server_constants.RIS_CODE_ERR, cart: 0 });
@@ -228,6 +232,14 @@ router.post('/:userId/createorderscart', authenticate, async function (req, res,
try {
let mycart = await Cart.findOne({ _id: cart_id });
if (!mycart) {
return res.send({
code: server_constants.RIS_CODE_OK,
status: 0,
recOrderCart: null,
});
}
let numorder = await OrdersCart.getLastNumOrder(idapp);
let numord_pers = await OrdersCart.getLastNumOrdPers(userId, idapp);