def render_userpage(UserName): listproduct = SQL.SelectAll("product") listcategory = SQL.SelectAllCategory() numpro = SQL.GetAmountProductInCart(UserName) return render_template('userpage.html', listitem=listproduct, listcategory=listcategory, UserName=UserName, cartAmount=numpro)
def search_user(UserName): listcategory = SQL.SelectAllCategory() numpro = SQL.GetAmountProductInCart(UserName) if request.method == "POST": text = request.form.get("search-data") listproduct = SQL.SelectFromText(text) return render_template('sub_userpage.html', listitem=listproduct, listcategory=listcategory, UserName=UserName, cartAmount=numpro)
def detailPro(UserName, id): numpro = SQL.GetAmountProductInCart(UserName) data = SQL.SelectProductById(id) cate = SQL.GetNameCategory(data[0][5]) listmore = SQL.SelectFromCategory(cate) return render_template("productDetail.html", UserName=UserName, cartAmount=numpro, data=data, cate=cate, listmore=listmore, id=id)
def loadCategory_user(UserName, category): listcategory = SQL.SelectAllCategory() numpro = SQL.GetAmountProductInCart(UserName) if (category == "all"): listproduct = SQL.SelectAll("product") return render_template('sub_userpage.html', listitem=listproduct, listcategory=listcategory, UserName=UserName, cartAmount=numpro) else: listproduct = SQL.SelectFromCategory(category) return render_template('sub_userpage.html', listitem=listproduct, listcategory=listcategory, UserName=UserName, cartAmount=numpro)
def render_cart(UserName): listitem = [] listproduct = SQL.SelectProductFromCart(UserName) total = 0 numpro = SQL.GetAmountProductInCart(UserName) if (len(listproduct) == 0): return render_template("Payment.html", listitem=listitem, total=round(total, 2), UserName=UserName, cartAmount=numpro) for item in listproduct: price = item[1] * item[3] item.append(round(price, 2)) total = total + price listitem.append(item) for i in listitem: print(i) return render_template("Payment.html", listitem=listitem, total=round(total, 2), UserName=UserName, cartAmount=numpro)