mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-19 03:17:55 +00:00
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:
@@ -39,7 +39,7 @@
|
||||
{{ doc.website_content or '' }}
|
||||
|
||||
<!-- Reviews and Comments -->
|
||||
{% if shopping_cart.cart_settings.enable_reviews %}
|
||||
{% if shopping_cart.cart_settings.enable_reviews and not doc.has_variants %}
|
||||
{% include "templates/generators/item/item_reviews.html"%}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -7,9 +7,21 @@
|
||||
<div class="col-md-12">
|
||||
<!-- Price and Availability -->
|
||||
{% if cart_settings.show_price and product_info.price %}
|
||||
{% set price_info = product_info.price %}
|
||||
|
||||
{% if price_info.formatted_mrp %}
|
||||
<small class="formatted-price">
|
||||
M.R.P.:
|
||||
<s>{{ price_info.formatted_mrp }}</s>
|
||||
</small>
|
||||
<small class="ml-2 formatted-price" style="color: #F47A7A; font-weight: 500;">
|
||||
{{ price_info.get("formatted_discount_percent") or price_info.get("formatted_discount_rate")}} OFF
|
||||
</small>
|
||||
{% endif %}
|
||||
|
||||
<div class="product-price">
|
||||
{{ product_info.price.formatted_price_sales_uom }}
|
||||
<small class="formatted-price">({{ product_info.price.formatted_price }} / {{ product_info.uom }})</small>
|
||||
{{ price_info.formatted_price_sales_uom }}
|
||||
<small class="formatted-price">({{ price_info.formatted_price }} / {{ product_info.uom }})</small>
|
||||
</div>
|
||||
{% else %}
|
||||
{{ _("UOM") }} : {{ product_info.uom }}
|
||||
|
||||
@@ -138,35 +138,47 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if is_featured %}
|
||||
<div class="product-price">{{ item.formatted_price or '' }}</div>
|
||||
<div class="product-description ellipsis">{{ description or '' }}</div>
|
||||
{% else %}
|
||||
<div class="product-category">{{ item.item_group or '' }}</div>
|
||||
<div style="display: flex;">
|
||||
{% if item.formatted_price %}
|
||||
<div class="product-price">{{ item.formatted_price or '' }}</div>
|
||||
{% endif %}
|
||||
{% if item.has_variants %}
|
||||
<a href="/{{ item.route or '#' }}">
|
||||
<div class="btn btn-sm btn-explore-variants">
|
||||
{{ _('Explore') }}
|
||||
<div class="product-description ellipsis">{{ description or '' }}</div>
|
||||
{% else %}
|
||||
<div class="product-category">{{ item.item_group or '' }}</div>
|
||||
|
||||
{% if item.formatted_price %}
|
||||
<div class="product-price">
|
||||
{{ item.formatted_price or '' }}
|
||||
|
||||
{% if item.get("formatted_mrp") %}
|
||||
<small class="ml-1 text-muted">
|
||||
<s>{{ item.formatted_mrp }}</s>
|
||||
</small>
|
||||
<small class="ml-1" style="color: #F47A7A; font-weight: 500;">
|
||||
{{ item.discount }} OFF
|
||||
</small>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</a>
|
||||
{% elif settings.enabled %}
|
||||
<div id="{{ item.name }}" class="btn btn-sm btn-add-to-cart-list not-added"
|
||||
{% endif %}
|
||||
|
||||
{% if item.has_variants %}
|
||||
<a href="/{{ item.route or '#' }}">
|
||||
<div class="btn btn-sm btn-explore-variants w-100 mt-4">
|
||||
{{ _('Explore') }}
|
||||
</div>
|
||||
</a>
|
||||
{% elif settings.enabled and (settings.allow_items_not_in_stock or item.in_stock != "red")%}
|
||||
<div id="{{ item.name }}" class="btn btn-sm btn-add-to-cart-list not-added w-100 mt-4"
|
||||
data-item-code="{{ item.item_code }}">
|
||||
{{ _('Add to Cart') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro wishlist_card(item, settings) %}
|
||||
<div class="col-sm-3 item-card">
|
||||
<div class="card text-center">
|
||||
<div class="col-sm-3 wishlist-card">
|
||||
<div class="card text-center" style="max-height: 390px;">
|
||||
{% if item.image %}
|
||||
<div class="card-img-container">
|
||||
<a href="/{{ item.route or '#' }}" style="text-decoration: none;">
|
||||
@@ -201,22 +213,33 @@
|
||||
<div style="margin-top: 16px;">
|
||||
<div class="product-title">{{ item.item_name or item.item_code or ''}}</div>
|
||||
</div>
|
||||
<div class="product-price">{{ item.formatted_price or '' }}</div>
|
||||
<div class="product-price">
|
||||
{{ item.formatted_price or '' }}
|
||||
|
||||
{% if item.get("formatted_mrp") %}
|
||||
<small class="ml-1 text-muted">
|
||||
<s>{{ item.formatted_mrp }}</s>
|
||||
</small>
|
||||
<small class="ml-1" style="color: #F47A7A; font-weight: 500;">
|
||||
{{ item.discount }} OFF
|
||||
</small>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if (item.available and settings.show_stock_availability) or (not settings.show_stock_availability) %}
|
||||
<!-- Show move to cart button if in stock or if showing stock availability is disabled -->
|
||||
<button data-item-code="{{ item.item_code}}" class="btn btn-add-to-cart w-100 wishlist-cart-not-added">
|
||||
<span class="mr-2">
|
||||
<svg class="icon icon-md">
|
||||
<use href="#icon-assets"></use>
|
||||
</svg>
|
||||
</span>
|
||||
{{ _("Move to Cart") }}
|
||||
</button>
|
||||
<!-- Show move to cart button if in stock or if showing stock availability is disabled -->
|
||||
<button data-item-code="{{ item.item_code}}" class="btn btn-add-to-cart w-100 wishlist-cart-not-added mt-2">
|
||||
<span class="mr-2">
|
||||
<svg class="icon icon-md">
|
||||
<use href="#icon-assets"></use>
|
||||
</svg>
|
||||
</span>
|
||||
{{ _("Move to Cart") }}
|
||||
</button>
|
||||
{% else %}
|
||||
<div style="color: #F47A7A; width: 100%;">
|
||||
{{ _("Not in Stock") }}
|
||||
</div>
|
||||
<div class="mt-4" style="color: #F47A7A; width: 100%;">
|
||||
{{ _("Not in Stock") }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{%- endmacro -%}
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
@@ -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("""
|
||||
|
||||
Reference in New Issue
Block a user