49 lines
1.5 KiB
Python
Raw Normal View History

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2014-10-21 16:16:30 +05:30
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
2015-02-23 22:14:12 +05:30
from frappe import _
2014-10-21 16:16:30 +05:30
import frappe.defaults
2015-02-23 22:14:12 +05:30
from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import is_cart_enabled
2014-10-21 16:16:30 +05:30
def show_cart_count():
if (frappe.db.get_default("shopping_cart_enabled") and
frappe.db.get_value("User", frappe.session.user, "user_type") == "Website User"):
return True
return False
def set_cart_count(login_manager):
if show_cart_count():
2015-02-23 22:14:12 +05:30
from erpnext.shopping_cart.cart import set_cart_count
2014-10-21 16:16:30 +05:30
set_cart_count()
def clear_cart_count(login_manager):
if show_cart_count():
frappe.local.cookie_manager.delete_cookie("cart_count")
2015-02-24 17:50:44 +05:30
def update_website_context(context):
2015-02-23 22:14:12 +05:30
cart_enabled = is_cart_enabled()
2014-10-21 16:16:30 +05:30
context["shopping_cart_enabled"] = cart_enabled
if cart_enabled:
2015-02-23 22:14:12 +05:30
post_login = [
{"label": _("Cart"), "url": "cart", "class": "cart-count"},
2014-10-21 16:16:30 +05:30
{"class": "divider"}
]
2015-02-23 22:14:12 +05:30
context["post_login"] = post_login + context.get("post_login", [])
def update_my_account_context(context):
if is_cart_enabled():
context["my_account_list"].append({"label": _("Cart"), "url": "cart"})
context["my_account_list"].extend([
{"label": _("Orders"), "url": "orders"},
{"label": _("Invoices"), "url": "invoices"},
{"label": _("Shipments"), "url": "shipments"},
2015-06-01 17:15:42 +05:30
{"label": _("Issues"), "url": "issues"},
2015-02-23 22:14:12 +05:30
{"label": _("Addresses"), "url": "addresses"},
])