feat: Wishlist Page

- Navbar icon with badge count for wishlist
- Wishlist page with cards
- Cards can be moved to cart or removed in a click
- Separated all wishlist related methods into wishlist.js
- Made a common js method(util) to add/remove wishlist items
- Bug fix: Make sure items are removed from session user's wishlist
This commit is contained in:
marination
2021-03-16 00:05:53 +05:30
parent 0783e3deac
commit 0b3921e3cf
11 changed files with 345 additions and 108 deletions

View File

@@ -0,0 +1,24 @@
{% extends "templates/web.html" %}
{% block title %} {{ _("Wishlist") }} {% endblock %}
{% block header %}<h3 class="shopping-cart-header mt-2 mb-6">{{ _("Wishlist") }}</h1>{% endblock %}
{% block page_content %}
{% if items %}
<div class="row">
<div class="col-12 col-md-11 item-card-group-section">
<div class="row products-list">
{% from "erpnext/templates/includes/macros.html" import wishlist_card %}
{% for item in items %}
{{ wishlist_card(item, settings) }}
{% endfor %}
</div>
</div>
</div>
{% else %}
<!-- TODO: Make empty state for wishlist -->
{% include "erpnext/www/all-products/not_found.html" %}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,39 @@
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
no_cache = 1
import frappe
from erpnext.e_commerce.shopping_cart.cart import get_cart_quotation
def get_context(context):
settings = frappe.get_doc("E Commerce Settings")
items = get_wishlist_items()
if settings.show_stock_availability:
for item in items:
stock_qty = frappe.utils.flt(
frappe.db.get_value("Bin",
{
"item_code": item.item_code,
"warehouse": item.get("warehouse")
},
"actual_qty")
)
item.available = True if stock_qty else False
context.items = items
context.settings = settings
def get_wishlist_items():
if frappe.db.exists("Wishlist", frappe.session.user):
return frappe.db.sql("""
Select
item_code, item_name, website_item, price,
warehouse, image, item_group, route, formatted_price
from
`tabWishlist Items`
where
parent=%(user)s"""%{"user": frappe.db.escape(frappe.session.user)}, as_dict=1)
return