feat: Slashed Prices and Discount display

- Registered mrp and price after discounts
- slashed price with discount in listing, item page and wishlist
- removed redundant imports
- renamed method to `get_web_item_qty_in_stock` to get Website Item stock
- adjusted styles for resizing
- made add to cart button full width on cards
This commit is contained in:
marination
2021-04-13 00:39:26 +05:30
parent 6d85e821c1
commit f10a08ad6b
14 changed files with 139 additions and 72 deletions

View File

@@ -7,7 +7,7 @@
{% block page_content %}
{% if items %}
<div class="row">
<div class="col-12 col-md-11 item-card-group-section">
<div class="col-md-12 item-card-group-section">
<div class="row products-list">
{% from "erpnext/templates/includes/macros.html" import wishlist_card %}
{% for item in items %}

View File

@@ -5,26 +5,45 @@ from __future__ import unicode_literals
no_cache = 1
import frappe
from erpnext.utilities.product import get_price
from erpnext.e_commerce.shopping_cart.cart import _set_price_list
def get_context(context):
settings = frappe.get_doc("E Commerce Settings")
items = get_wishlist_items()
selling_price_list = _set_price_list(settings)
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
for item in items:
if settings.show_stock_availability:
item.available = get_stock_availability(item.item_code, item.get("warehouse"))
price_details = get_price(
item.item_code,
selling_price_list,
settings.default_customer_group,
settings.company
)
if price_details:
item.formatted_mrp = price_details.get('formatted_mrp')
if item.formatted_mrp:
item.discount = price_details.get('formatted_discount_percent') or \
price_details.get('formatted_discount_rate')
context.items = items
context.settings = settings
def get_stock_availability(item_code, warehouse):
stock_qty = frappe.utils.flt(
frappe.db.get_value("Bin",
{
"item_code": item_code,
"warehouse": warehouse
},
"actual_qty")
)
return True if stock_qty else False
def get_wishlist_items():
if frappe.db.exists("Wishlist", frappe.session.user):
return frappe.db.sql("""