Spaces:
Runtime error
Runtime error
Update cart.py
Browse files
cart.py
CHANGED
@@ -375,7 +375,7 @@ def checkout():
|
|
375 |
def get_loyalty_data():
|
376 |
email = session.get('user_email')
|
377 |
if not email:
|
378 |
-
return
|
379 |
|
380 |
try:
|
381 |
# Fetch customer loyalty data
|
@@ -385,7 +385,7 @@ def get_loyalty_data():
|
|
385 |
""")
|
386 |
customer = customer_record.get("records", [])[0] if customer_record["records"] else None
|
387 |
if not customer:
|
388 |
-
return
|
389 |
|
390 |
# Define available rewards
|
391 |
rewards = [
|
@@ -401,13 +401,7 @@ def get_loyalty_data():
|
|
401 |
"badge": customer.get("Badge__c", "Newbie"),
|
402 |
"available_rewards": rewards
|
403 |
}
|
404 |
-
return
|
405 |
|
406 |
except Exception as e:
|
407 |
-
return
|
408 |
-
@cart_blueprint.route("/loyalty_page", methods=["GET"])
|
409 |
-
def loyalty_page():
|
410 |
-
email = session.get('user_email')
|
411 |
-
if not email:
|
412 |
-
return redirect(url_for('login')) # Redirect to login if not authenticated
|
413 |
-
return render_template("loyalty.html") # Render the loyalty page
|
|
|
375 |
def get_loyalty_data():
|
376 |
email = session.get('user_email')
|
377 |
if not email:
|
378 |
+
return redirect(url_for('login')) # Redirect to login if not authenticated
|
379 |
|
380 |
try:
|
381 |
# Fetch customer loyalty data
|
|
|
385 |
""")
|
386 |
customer = customer_record.get("records", [])[0] if customer_record["records"] else None
|
387 |
if not customer:
|
388 |
+
return "Customer not found", 404
|
389 |
|
390 |
# Define available rewards
|
391 |
rewards = [
|
|
|
401 |
"badge": customer.get("Badge__c", "Newbie"),
|
402 |
"available_rewards": rewards
|
403 |
}
|
404 |
+
return render_template("loyalty.html", loyalty_data=loyalty_data)
|
405 |
|
406 |
except Exception as e:
|
407 |
+
return f"Error: {str(e)}", 500
|
|
|
|
|
|
|
|
|
|
|
|