having issues trying to implement a feature to add things/delete thing from a shopping cart [closed]

15 hours ago 1
ARTICLE AD BOX

How do I build a simple shopping cart in Flask where I can add multiple products and then show everything on a cart page?How do I build a simple shopping cart in Flask where I can add multiple products and then show everything on a cart page?

@app.route('/checkout', methods=['POST']) def checkout(): user_id = session.get('user_id') cart = session.get('cart', []) order_type = request.form['order_type'] conn = get_db() c = conn.cursor() for item in cart: c.execute(''' INSERT INTO orders (user_id, product_id, quantity, order_type, status) VALUES (?, ?, ?, ?, ?) ''', (user_id, item['id'], item['quantity'], order_type, "Pending")) conn.commit() conn.close() session.pop('cart', None) return redirect('/orders')
Read Entire Article