chore: Removed Shopping Cart Module
- Moved all files and web templates from Shopping Cart to E-commerce module - Made Shopping Cart module obsolete - Moved select E-commerce related files from Portal to E-commerce module - Minor cleanups - Fixed Shopping Cart and Product Configurator tests
This commit is contained in:
41
erpnext/e_commerce/shopping_cart/utils.py
Normal file
41
erpnext/e_commerce/shopping_cart/utils.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import frappe.defaults
|
||||
from erpnext.e_commerce.doctype.e_commerce_settings.e_commerce_settings import is_cart_enabled
|
||||
|
||||
def show_cart_count():
|
||||
if (is_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):
|
||||
role, parties = check_customer_or_supplier()
|
||||
if role == 'Supplier': return
|
||||
if show_cart_count():
|
||||
from erpnext.e_commerce.shopping_cart.cart import set_cart_count
|
||||
set_cart_count()
|
||||
|
||||
def clear_cart_count(login_manager):
|
||||
if show_cart_count():
|
||||
frappe.local.cookie_manager.delete_cookie("cart_count")
|
||||
|
||||
def update_website_context(context):
|
||||
cart_enabled = is_cart_enabled()
|
||||
context["shopping_cart_enabled"] = cart_enabled
|
||||
|
||||
def check_customer_or_supplier():
|
||||
if frappe.session.user:
|
||||
contact_name = frappe.get_value("Contact", {"email_id": frappe.session.user})
|
||||
if contact_name:
|
||||
contact = frappe.get_doc('Contact', contact_name)
|
||||
for link in contact.links:
|
||||
if link.link_doctype in ('Customer', 'Supplier'):
|
||||
return link.link_doctype, link.link_name
|
||||
|
||||
return 'Customer', None
|
||||
Reference in New Issue
Block a user