fix: Rename Wishlist Item, Use Website Item Name in Wishlist Cards
- Renamed Wishlist Items to Wishlist Item
- Use Website Item Name in Wishlist
- Add Website Item Name field in Wishlist Item
- Remove accidental extra `font-size` attribute
diff --git a/erpnext/e_commerce/doctype/website_item/website_item.py b/erpnext/e_commerce/doctype/website_item/website_item.py
index 3331532..8d3127e 100644
--- a/erpnext/e_commerce/doctype/website_item/website_item.py
+++ b/erpnext/e_commerce/doctype/website_item/website_item.py
@@ -195,7 +195,7 @@
get_item_reviews(self.name, 0, 4, context)
context.wished = False
- if frappe.db.exists("Wishlist Items", {"item_code": self.item_code, "parent": frappe.session.user}):
+ if frappe.db.exists("Wishlist Item", {"item_code": self.item_code, "parent": frappe.session.user}):
context.wished = True
context.user_is_customer = check_if_user_is_customer()
diff --git a/erpnext/e_commerce/doctype/wishlist/wishlist.json b/erpnext/e_commerce/doctype/wishlist/wishlist.json
index ae24207..922924e 100644
--- a/erpnext/e_commerce/doctype/wishlist/wishlist.json
+++ b/erpnext/e_commerce/doctype/wishlist/wishlist.json
@@ -28,13 +28,13 @@
"fieldname": "items",
"fieldtype": "Table",
"label": "Items",
- "options": "Wishlist Items"
+ "options": "Wishlist Item"
}
],
"in_create": 1,
"index_web_pages_for_search": 1,
"links": [],
- "modified": "2021-03-24 20:42:58.402031",
+ "modified": "2021-07-08 13:11:21.693956",
"modified_by": "Administrator",
"module": "E-commerce",
"name": "Wishlist",
diff --git a/erpnext/e_commerce/doctype/wishlist/wishlist.py b/erpnext/e_commerce/doctype/wishlist/wishlist.py
index c817657..94f19ff 100644
--- a/erpnext/e_commerce/doctype/wishlist/wishlist.py
+++ b/erpnext/e_commerce/doctype/wishlist/wishlist.py
@@ -13,11 +13,11 @@
def add_to_wishlist(item_code, price, formatted_price=None):
"""Insert Item into wishlist."""
- if frappe.db.exists("Wishlist Items", {"item_code": item_code, "parent": frappe.session.user}):
+ if frappe.db.exists("Wishlist Item", {"item_code": item_code, "parent": frappe.session.user}):
return
web_item_data = frappe.db.get_value("Website Item", {"item_code": item_code},
- ["image", "website_warehouse", "name", "item_name", "item_group", "route"]
+ ["image", "website_warehouse", "name", "web_item_name", "item_name", "item_group", "route"]
, as_dict=1)
wished_item_dict = {
@@ -25,6 +25,7 @@
"item_name": web_item_data.get("item_name"),
"item_group": web_item_data.get("item_group"),
"website_item": web_item_data.get("name"),
+ "web_item_name": web_item_data.get("web_item_name"),
"price": frappe.utils.flt(price),
"formatted_price": formatted_price,
"image": web_item_data.get("image"),
@@ -48,10 +49,10 @@
@frappe.whitelist()
def remove_from_wishlist(item_code):
- if frappe.db.exists("Wishlist Items", {"item_code": item_code, "parent": frappe.session.user}):
+ if frappe.db.exists("Wishlist Item", {"item_code": item_code, "parent": frappe.session.user}):
frappe.db.sql("""
delete
- from `tabWishlist Items`
+ from `tabWishlist Item`
where item_code=%(item_code)s
""" % {"item_code": frappe.db.escape(item_code)})
diff --git a/erpnext/e_commerce/doctype/wishlist_items/__init__.py b/erpnext/e_commerce/doctype/wishlist_item/__init__.py
similarity index 100%
rename from erpnext/e_commerce/doctype/wishlist_items/__init__.py
rename to erpnext/e_commerce/doctype/wishlist_item/__init__.py
diff --git a/erpnext/e_commerce/doctype/wishlist_items/wishlist_items.json b/erpnext/e_commerce/doctype/wishlist_item/wishlist_item.json
similarity index 90%
rename from erpnext/e_commerce/doctype/wishlist_items/wishlist_items.json
rename to erpnext/e_commerce/doctype/wishlist_item/wishlist_item.json
index 6623921..aecdbdd 100644
--- a/erpnext/e_commerce/doctype/wishlist_items/wishlist_items.json
+++ b/erpnext/e_commerce/doctype/wishlist_item/wishlist_item.json
@@ -7,6 +7,7 @@
"field_order": [
"item_code",
"website_item",
+ "web_item_name",
"column_break_3",
"item_name",
"item_group",
@@ -126,15 +127,23 @@
"fieldname": "formatted_price",
"fieldtype": "Data",
"label": "Formatted Price"
+ },
+ {
+ "fetch_from": "website_item.web_item_name",
+ "fetch_if_empty": 1,
+ "fieldname": "web_item_name",
+ "fieldtype": "Data",
+ "label": "Webiste Item Name",
+ "read_only": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
- "modified": "2021-03-18 16:04:52.965613",
+ "modified": "2021-07-08 13:14:14.919749",
"modified_by": "Administrator",
"module": "E-commerce",
- "name": "Wishlist Items",
+ "name": "Wishlist Item",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
diff --git a/erpnext/e_commerce/doctype/wishlist_items/wishlist_items.py b/erpnext/e_commerce/doctype/wishlist_item/wishlist_item.py
similarity index 88%
rename from erpnext/e_commerce/doctype/wishlist_items/wishlist_items.py
rename to erpnext/e_commerce/doctype/wishlist_item/wishlist_item.py
index 25ce17d..ee08cfe 100644
--- a/erpnext/e_commerce/doctype/wishlist_items/wishlist_items.py
+++ b/erpnext/e_commerce/doctype/wishlist_item/wishlist_item.py
@@ -6,5 +6,5 @@
# import frappe
from frappe.model.document import Document
-class WishlistItems(Document):
+class WishlistItem(Document):
pass
diff --git a/erpnext/e_commerce/product_query.py b/erpnext/e_commerce/product_query.py
index e5af7e1..b4d3bed 100644
--- a/erpnext/e_commerce/product_query.py
+++ b/erpnext/e_commerce/product_query.py
@@ -74,7 +74,7 @@
self.get_stock_availability(item)
item.wished = False
- if frappe.db.exists("Wishlist Items", {"item_code": item.item_code, "parent": frappe.session.user}):
+ if frappe.db.exists("Wishlist Item", {"item_code": item.item_code, "parent": frappe.session.user}):
item.wished = True
discounts = []
diff --git a/erpnext/public/scss/shopping_cart.scss b/erpnext/public/scss/shopping_cart.scss
index 4e948c1..5f0f023 100644
--- a/erpnext/public/scss/shopping_cart.scss
+++ b/erpnext/public/scss/shopping_cart.scss
@@ -73,7 +73,6 @@
border-radius: var(--border-radius);
font-size: 2rem;
color: var(--gray-500);
- font-size: 52px;
display: flex;
align-items: center;
justify-content: center;
diff --git a/erpnext/templates/includes/macros.html b/erpnext/templates/includes/macros.html
index a4bba5c..8413bb0 100644
--- a/erpnext/templates/includes/macros.html
+++ b/erpnext/templates/includes/macros.html
@@ -144,7 +144,7 @@
{%- macro wishlist_card(item, settings) %}
-{%- set title = item.item_name or item.item_code -%}
+{%- set title = item.web_item_name or ''-%}
{%- set title = title[:50] + "..." if title|len > 50 else title -%}
<div class="col-sm-3 wishlist-card">
<div class="card text-center" style="height: 100%">
@@ -167,15 +167,15 @@
</div>
</div>
- {{ wishlist_card_body(item, settings) }}
+ {{ wishlist_card_body(item, title, settings) }}
</div>
</div>
{%- endmacro -%}
-{%- macro wishlist_card_body(item, settings) %}
+{%- macro wishlist_card_body(item, title, settings) %}
<div class="card-body text-center" style="width: 100%;">
<div style="margin-top: 16px;">
- <div class="product-title">{{ item.item_name or item.item_code or ''}}</div>
+ <div class="product-title">{{ title or ''}}</div>
</div>
<div class="product-price">
{{ item.formatted_price or '' }}
diff --git a/erpnext/templates/pages/wishlist.py b/erpnext/templates/pages/wishlist.py
index 9bbec33..5992863 100644
--- a/erpnext/templates/pages/wishlist.py
+++ b/erpnext/templates/pages/wishlist.py
@@ -45,10 +45,10 @@
if frappe.db.exists("Wishlist", frappe.session.user):
return frappe.db.sql("""
Select
- item_code, item_name, website_item, price,
+ web_item_name, item_code, item_name, website_item, price,
warehouse, image, item_group, route, formatted_price
from
- `tabWishlist Items`
+ `tabWishlist Item`
where
parent=%(user)s""", {"user": frappe.session.user}, as_dict=1)
return
\ No newline at end of file