def modalProducts(): order = getOrderByCartStatus(session['user_id']) products_arr = [] for i in listOrderProductByOrderId(order.id): products_arr.append({'product_id': i.product_id, 'product_name': i.product.name, 'dimension': i.dimension.name, 'dimension_id': i.dimension_id, 'quantity': i.quantity, 'price': str(i.price)}) return make_response(jsonify(products=products_arr), 200)
def updateOrderProduct(): total_price = 0 order_number = random.randint(0,999999) order = getOrderByCartStatus(session['user_id']) for i in OrderProduct.listOrderProductById(order.id): total_price += i.price*i.quantity Order.updateOrderStatus(order.id, OrderStatus.getNameStatus('Created').id, total_price, order_number) return make_response(jsonify({'message':'success'}),200)
def deleteOrderProduct(): order = getOrderByCartStatus(session['user_id']) OrderProduct.delete_order_product(order.id, request.args.get('product_id'), request.args.get('dimension_id')) return make_response(jsonify({'message': 'success'}), 200)