def show_cart():
    """List items in shopping cart, prices, and total"""
    total_price = 0
    cart_list = [Product.get_by_id(id) for id in session['cart']]

    for product in cart_list:
        total_price += product.price

    return render_template("cart.html", total=total_price, products=cart_list)
Example #2
0
def show_cart():
    """Show shopping cart."""
    product_id = request.form["product_id"]
    product = Product.get_by_id()
    return render_template("cart.html", product=product)
Example #3
0
def product_detail(product_id):
    """Show detail of product, along with add-to-cart form."""
    product_id = Product.get_by_id(product_id)
    return render_template("product.html", product_id=product_id)