def delete(product_id): cart_data = request.cookies.get('cart', '{}') cart = Cart(cart_data) cart.remove(product_id) response = make_response(redirect(url_for('cart.view'), code=302)) response.set_cookie('cart', cart.jsonified_data) return response
def update(product_id): cart_data = request.cookies.get('cart', '{}') cart = Cart(cart_data) form_data = request.form.to_dict() quantity = int(form_data.get('quantity', 1)) cart.update(product_id, quantity) response = make_response(redirect(url_for('cart.view'), code=302)) response.set_cookie('cart', cart.jsonified_data) return response