From 2fec068aff4d8be2e2cf4090061877c1fdba6ad1 Mon Sep 17 00:00:00 2001 From: marination Date: Tue, 13 Jul 2021 23:46:24 +0530 Subject: [PATCH] feat: Recommended Items and Item full page refresh - Added Optional Recommended Items - Item Full Page minor UI Refresh - Floating wishlist button in item full page - Reviews section UI Refresh --- .../e_commerce_settings.json | 14 +- .../doctype/recommended_items/__init__.py | 0 .../recommended_items/recommended_items.json | 87 ++++++++ .../recommended_items/recommended_items.py | 8 + .../doctype/website_item/website_item.json | 20 +- .../doctype/website_item/website_item.py | 40 ++++ erpnext/e_commerce/website_item_indexing.py | 1 + erpnext/public/js/shopping_cart.js | 10 + erpnext/public/js/wishlist.js | 90 +++++---- erpnext/public/scss/shopping_cart.scss | 189 ++++++++++++++++-- erpnext/templates/generators/item/item.html | 74 ++++--- .../generators/item/item_add_to_cart.html | 122 ++++------- .../generators/item/item_details.html | 87 +++++--- .../generators/item/item_inquiry.html | 2 +- .../generators/item/item_reviews.html | 38 ++-- .../generators/item/item_specifications.html | 10 +- erpnext/templates/includes/macros.html | 134 +++++++++---- erpnext/templates/pages/customer_reviews.html | 36 ++-- erpnext/templates/pages/customer_reviews.py | 2 + 19 files changed, 690 insertions(+), 274 deletions(-) create mode 100644 erpnext/e_commerce/doctype/recommended_items/__init__.py create mode 100644 erpnext/e_commerce/doctype/recommended_items/recommended_items.json create mode 100644 erpnext/e_commerce/doctype/recommended_items/recommended_items.py diff --git a/erpnext/e_commerce/doctype/e_commerce_settings/e_commerce_settings.json b/erpnext/e_commerce/doctype/e_commerce_settings/e_commerce_settings.json index 232a0612cc..8eeaf53015 100644 --- a/erpnext/e_commerce/doctype/e_commerce_settings/e_commerce_settings.json +++ b/erpnext/e_commerce/doctype/e_commerce_settings/e_commerce_settings.json @@ -27,6 +27,8 @@ "enable_wishlist", "column_break_22", "enable_reviews", + "column_break_23", + "enable_recommendations", "section_break_18", "company", "price_list", @@ -367,12 +369,22 @@ { "fieldname": "column_break_22", "fieldtype": "Column Break" + }, + { + "fieldname": "column_break_23", + "fieldtype": "Column Break" + }, + { + "default": "0", + "fieldname": "enable_recommendations", + "fieldtype": "Check", + "label": "Enable Recommendations" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2021-07-07 21:32:17.363276", + "modified": "2021-07-13 16:30:14.715949", "modified_by": "Administrator", "module": "E-commerce", "name": "E Commerce Settings", diff --git a/erpnext/e_commerce/doctype/recommended_items/__init__.py b/erpnext/e_commerce/doctype/recommended_items/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/e_commerce/doctype/recommended_items/recommended_items.json b/erpnext/e_commerce/doctype/recommended_items/recommended_items.json new file mode 100644 index 0000000000..06ac3dc03b --- /dev/null +++ b/erpnext/e_commerce/doctype/recommended_items/recommended_items.json @@ -0,0 +1,87 @@ +{ + "actions": [], + "creation": "2021-07-12 20:52:12.503470", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "website_item", + "website_item_name", + "column_break_2", + "item_code", + "more_information_section", + "route", + "column_break_6", + "website_item_image", + "website_item_thumbnail" + ], + "fields": [ + { + "fieldname": "website_item", + "fieldtype": "Link", + "in_list_view": 1, + "label": "Website Item", + "options": "Website Item" + }, + { + "fetch_from": "website_item.web_item_name", + "fieldname": "website_item_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Website Item Name", + "read_only": 1 + }, + { + "fieldname": "column_break_2", + "fieldtype": "Column Break" + }, + { + "fieldname": "more_information_section", + "fieldtype": "Section Break", + "label": "More Information" + }, + { + "fetch_from": "website_item.route", + "fieldname": "route", + "fieldtype": "Small Text", + "label": "Route", + "read_only": 1 + }, + { + "fetch_from": "website_item.image", + "fieldname": "website_item_image", + "fieldtype": "Attach", + "label": "Website Item Image", + "read_only": 1 + }, + { + "fieldname": "column_break_6", + "fieldtype": "Column Break" + }, + { + "fetch_from": "website_item.thumbnail", + "fieldname": "website_item_thumbnail", + "fieldtype": "Data", + "label": "Website Item Thumbnail", + "read_only": 1 + }, + { + "fetch_from": "website_item.item_code", + "fieldname": "item_code", + "fieldtype": "Data", + "label": "Item Code" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2021-07-13 21:02:19.031652", + "modified_by": "Administrator", + "module": "E-commerce", + "name": "Recommended Items", + "owner": "Administrator", + "permissions": [], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/erpnext/e_commerce/doctype/recommended_items/recommended_items.py b/erpnext/e_commerce/doctype/recommended_items/recommended_items.py new file mode 100644 index 0000000000..9782abdec6 --- /dev/null +++ b/erpnext/e_commerce/doctype/recommended_items/recommended_items.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class RecommendedItems(Document): + pass diff --git a/erpnext/e_commerce/doctype/website_item/website_item.json b/erpnext/e_commerce/doctype/website_item/website_item.json index a321584c78..c33cb51ea3 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.json +++ b/erpnext/e_commerce/doctype/website_item/website_item.json @@ -39,6 +39,8 @@ "display_additional_information_section", "show_tabbed_section", "tabs", + "recommended_items_section", + "recommended_items", "offers_section", "offers", "section_break_6", @@ -312,13 +314,25 @@ "fieldname": "short_description", "fieldtype": "Small Text", "label": "Short Website Description" + }, + { + "collapsible": 1, + "fieldname": "recommended_items_section", + "fieldtype": "Section Break", + "label": "Recommended Items" + }, + { + "fieldname": "recommended_items", + "fieldtype": "Table", + "label": "Recommended/Similar Items", + "options": "Recommended Items" } ], "has_web_view": 1, "image_field": "image", "index_web_pages_for_search": 1, "links": [], - "modified": "2021-07-11 20:49:45.415421", + "modified": "2021-07-12 21:00:04.065803", "modified_by": "Administrator", "module": "E-commerce", "name": "Website Item", @@ -373,10 +387,10 @@ "write": 1 } ], - "search_fields": "item_code, item_name ,item_group", + "search_fields": "web_item_name, item_code, item_group", "show_name_in_global_search": 1, "sort_field": "modified", "sort_order": "DESC", - "title_field": "item_name", + "title_field": "web_item_name", "track_changes": 1 } \ No newline at end of file diff --git a/erpnext/e_commerce/doctype/website_item/website_item.py b/erpnext/e_commerce/doctype/website_item/website_item.py index 3ff58fdf71..081c4bbae6 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.py +++ b/erpnext/e_commerce/doctype/website_item/website_item.py @@ -13,6 +13,8 @@ from frappe.website.doctype.website_slideshow.website_slideshow import get_slide from erpnext.setup.doctype.item_group.item_group import (get_parent_item_groups, invalidate_cache_for) from erpnext.e_commerce.doctype.item_review.item_review import get_item_reviews +from erpnext.e_commerce.shopping_cart.cart import _set_price_list +from erpnext.utilities.product import get_price # SEARCH from erpnext.e_commerce.website_item_indexing import ( @@ -199,6 +201,12 @@ class WebsiteItem(WebsiteGenerator): context.wished = True context.user_is_customer = check_if_user_is_customer() + + context.recommended_items = None + settings = context.shopping_cart.cart_settings + if settings.enable_recommendations: + context.recommended_items = self.get_recommended_items(settings) + return context def set_variant_context(self, context): @@ -379,6 +387,38 @@ class WebsiteItem(WebsiteGenerator): return tab_values + def get_recommended_items(self, settings): + items = frappe.db.sql(f""" + select + ri.website_item_thumbnail, ri.website_item_name, + ri.route, ri.item_code + from + `tabRecommended Items` ri, `tabWebsite Item` wi + where + ri.item_code = wi.item_code + and ri.parent = '{self.name}' + and wi.published = 1 + order by ri.idx + """, as_dict=1) + + if settings.show_price: + is_guest = frappe.session.user == "Guest" + # Show Price if logged in. + # If not logged in and price is hidden for guest, skip price fetch. + if is_guest and settings.hide_price_for_guest: + return items + + selling_price_list = _set_price_list(settings, None) + for item in items: + item.price_info = get_price( + item.item_code, + selling_price_list, + settings.default_customer_group, + settings.company + ) + + return items + def invalidate_cache_for_web_item(doc): """Invalidate Website Item Group cache and rebuild ItemVariantsCacheManager.""" from erpnext.stock.doctype.item.item import invalidate_item_variants_cache_for_website diff --git a/erpnext/e_commerce/website_item_indexing.py b/erpnext/e_commerce/website_item_indexing.py index 18dac93ad3..f66d2ef0e8 100644 --- a/erpnext/e_commerce/website_item_indexing.py +++ b/erpnext/e_commerce/website_item_indexing.py @@ -11,6 +11,7 @@ WEBSITE_ITEM_NAME_AUTOCOMPLETE = 'website_items_name_dict' WEBSITE_ITEM_CATEGORY_AUTOCOMPLETE = 'website_items_category_dict' ALLOWED_INDEXABLE_FIELDS_SET = { + 'web_item_name', 'item_code', 'item_name', 'item_group', diff --git a/erpnext/public/js/shopping_cart.js b/erpnext/public/js/shopping_cart.js index be0c21f0ce..4c134e2dff 100644 --- a/erpnext/public/js/shopping_cart.js +++ b/erpnext/public/js/shopping_cart.js @@ -176,6 +176,16 @@ $.extend(shopping_cart, { const $btn = $(e.currentTarget); $btn.prop('disabled', true); + if (frappe.session.user==="Guest") { + if (localStorage) { + localStorage.setItem("last_visited", window.location.pathname); + } + frappe.call('erpnext.e_commerce.api.get_guest_redirect_on_action').then((res) => { + window.location.href = res.message || "/login"; + }); + return; + } + $btn.addClass('hidden'); $btn.parent().find('.go-to-cart').removeClass('hidden'); $btn.parent().find('.go-to-cart-grid').removeClass('hidden'); diff --git a/erpnext/public/js/wishlist.js b/erpnext/public/js/wishlist.js index 4333587dc6..3c8d842bea 100644 --- a/erpnext/public/js/wishlist.js +++ b/erpnext/public/js/wishlist.js @@ -81,53 +81,55 @@ $.extend(wishlist, { // 'wish'('like') or 'unwish' item in product listing $('.page_content').on('click', '.like-action, .like-action-list', (e) => { const $btn = $(e.currentTarget); - const $wish_icon = $btn.find('.wish-icon'); - let me = this; - - if (frappe.session.user==="Guest") { - if (localStorage) { - localStorage.setItem("last_visited", window.location.pathname); - } - - this.redirect_guest(); - - return; - } - - let success_action = function() { - e_commerce.wishlist.set_wishlist_count(); - }; - - if ($wish_icon.hasClass('wished')) { - // un-wish item - $btn.removeClass("like-animate"); - $btn.addClass("like-action-wished"); - this.toggle_button_class($wish_icon, 'wished', 'not-wished'); - - let args = { item_code: $btn.data('item-code') }; - let failure_action = function() { - me.toggle_button_class($wish_icon, 'not-wished', 'wished'); - }; - this.add_remove_from_wishlist("remove", args, success_action, failure_action); - } else { - // wish item - $btn.addClass("like-animate"); - $btn.addClass("like-action-wished"); - this.toggle_button_class($wish_icon, 'not-wished', 'wished'); - - let args = { - item_code: $btn.data('item-code'), - price: $btn.data('price'), - formatted_price: $btn.data('formatted-price') - }; - let failure_action = function() { - me.toggle_button_class($wish_icon, 'wished', 'not-wished'); - }; - this.add_remove_from_wishlist("add", args, success_action, failure_action); - } + this.wishlist_action($btn); }); }, + wishlist_action(btn) { + const $wish_icon = btn.find('.wish-icon'); + let me = this; + + if (frappe.session.user==="Guest") { + if (localStorage) { + localStorage.setItem("last_visited", window.location.pathname); + } + this.redirect_guest(); + return; + } + + let success_action = function() { + e_commerce.wishlist.set_wishlist_count(); + }; + + if ($wish_icon.hasClass('wished')) { + // un-wish item + btn.removeClass("like-animate"); + btn.addClass("like-action-wished"); + this.toggle_button_class($wish_icon, 'wished', 'not-wished'); + + let args = { item_code: btn.data('item-code') }; + let failure_action = function() { + me.toggle_button_class($wish_icon, 'not-wished', 'wished'); + }; + this.add_remove_from_wishlist("remove", args, success_action, failure_action); + } else { + // wish item + btn.addClass("like-animate"); + btn.addClass("like-action-wished"); + this.toggle_button_class($wish_icon, 'not-wished', 'wished'); + + let args = { + item_code: btn.data('item-code'), + price: btn.data('price'), + formatted_price: btn.data('formatted-price') + }; + let failure_action = function() { + me.toggle_button_class($wish_icon, 'wished', 'not-wished'); + }; + this.add_remove_from_wishlist("add", args, success_action, failure_action); + } + }, + toggle_button_class(button, remove, add) { button.removeClass(remove); button.addClass(add); diff --git a/erpnext/public/scss/shopping_cart.scss b/erpnext/public/scss/shopping_cart.scss index 27270f3517..0130e70302 100644 --- a/erpnext/public/scss/shopping_cart.scss +++ b/erpnext/public/scss/shopping_cart.scss @@ -2,6 +2,7 @@ :root { --green-info: #38A160; + --product-bg-color: white; } body.product-page { @@ -289,6 +290,7 @@ body.product-page { .product-container { @include card($padding: var(--padding-md)); + background-color: var(--product-bg-color) !important; min-height: 70vh; .product-details { @@ -299,6 +301,12 @@ body.product-page { } } + &.item-main { + .product-image { + width: 100%; + } + } + .expand { max-width: 100% !important; // expand in absence of slideshow } @@ -327,9 +335,10 @@ body.product-page { } .product-title { - font-size: 24px; + font-size: 16px; font-weight: 600; color: var(--text-color); + padding: 0 !important; } .product-description { @@ -385,7 +394,7 @@ body.product-page { .item-cart { .product-price { - font-size: 20px; + font-size: 22px; color: var(--text-color); font-weight: 600; @@ -398,12 +407,94 @@ body.product-page { .no-stock { font-size: var(--text-base); } + + .offers-heading { + font-size: 16px !important; + color: var(--text-color); + .tag-icon { + --icon-stroke: var(--gray-500); + } + } + + .w-30-40 { + width: 30%; + + @media (max-width: 992px) { + width: 40%; + } + } + } + + .tab-content { + font-size: 14px; + } +} + +// Item Recommendations +.recommended-item-section { + padding-right: 0; + + .recommendation-header { + font-size: 16px; + font-weight: 500 + } + + .recommendation-container { + padding: .5rem; + min-height: 0px; + + .r-item-image { + width: 40%; + + .no-image-r-item { + display: flex; justify-content: center; + background-color: var(--gray-200); + align-items: center; + color: var(--gray-400); + margin-top: .15rem; + border-radius: 6px; + height: 100%; + font-size: 24px; + } + } + + .r-item-info { + font-size: 14px; + padding-left: 8px; + padding-right: 0; + width: 60%; + + a { + color: var(--gray-800); + font-weight: 400; + } + + .item-price { + font-size: 15px; + font-weight: 600; + color: var(--text-color); + } + + .striked-item-price { + font-weight: 500; + color: var(--gray-500); + } + } } } .product-code { + padding: .5rem 0; color: var(--text-muted); font-size: 14px; + .product-item-group { + padding-right: .25rem; + border-right: solid 1px var(--text-muted); + } + + .product-item-code { + padding-left: .5rem; + } } .item-configurator-dialog { @@ -794,6 +885,12 @@ body.product-page { } } +.like-action-item-fp { + visibility: visible !important; + position: unset; + float: right; +} + .like-animate { animation: expand cubic-bezier(0.04, 0.4, 0.5, 0.95) 1.6s forwards 1; } @@ -919,16 +1016,63 @@ body.product-page { .item-website-specification { font-size: .875rem; + .product-title { + font-size: 18px; + } + + .table { + width: 70%; + } + + td { + border: none !important; + } + + .spec-label { + color: var(--gray-600); + } + + .spec-content { + color: var(--gray-800); + } +} + +.reviews-full-page { + padding: 1rem 2rem; } .ratings-reviews-section { border-top: 1px solid #E2E6E9; + padding: .5rem 1rem; } .reviews-header { font-size: 20px; font-weight: 600; color: var(--gray-800); + display: flex; + align-items: center; + padding: 0; +} + +.btn-write-review { + float: right; + padding: .5rem 1rem; + font-size: 14px; + font-weight: 400; + border: none !important; + box-shadow: none; + + color: var(--gray-900); + background-color: var(--gray-100); + + &:hover { + box-shadow: var(--btn-shadow); + } +} + +.rating-summary-section { + display: flex; } .rating-summary-title { @@ -936,9 +1080,17 @@ body.product-page { font-size: 18px; } +.rating-summary-numbers { + display: flex; + flex-direction: column; + align-items: center; + + border-right: solid 1px var(--gray-100); +} + .user-review-title { margin-top: 0.15rem; - font-size: 16px; + font-size: 15px; font-weight: 600; } @@ -952,6 +1104,12 @@ body.product-page { } } +.ratings-pill { + background-color: var(--gray-100); + padding: .5rem 1rem; + border-radius: 66px; +} + .review { max-width: 80%; line-height: 1.6; @@ -961,21 +1119,18 @@ body.product-page { .review-signature { display: flex; - font-size: 14px; + font-size: 13px; color: var(--gray-500); font-weight: 400; .reviewer { padding-right: 8px; - margin-right: 8px; - border-right: 1px solid var(--gray-400); + color: var(--gray-600); } } .rating-progress-bar-section { padding-bottom: 2rem; - border-bottom: 1px solid #E2E6E9; - margin-right: -10px; .rating-bar-title { margin-left: -15px; @@ -985,14 +1140,15 @@ body.product-page { margin-bottom: 4px; height: 7px; margin-top: 6px; + + .progress-bar-cosmetic { + background-color: var(--gray-600); + border-radius: var(--border-radius); + } } } .offer-container { - border: 1px solid var(--gray-300); - border-style: dashed; - border-radius: 4px; - padding: 6px; font-size: 14px; } @@ -1075,3 +1231,12 @@ body.product-page { .font-md { font-size: 14px !important; } + +.in-green { + color: var(--green-info) !important; + font-weight: 500; +} + +.mt-minus-2 { + margin-top: -2rem; +} diff --git a/erpnext/templates/generators/item/item.html b/erpnext/templates/generators/item/item.html index 427e568aa8..e19cfb0b46 100644 --- a/erpnext/templates/generators/item/item.html +++ b/erpnext/templates/generators/item/item.html @@ -1,4 +1,5 @@ {% extends "templates/web.html" %} +{% from "erpnext/templates/includes/macros.html" import recommended_item_row %} {% block title %} {{ title }} {% endblock %} @@ -9,7 +10,7 @@ {% endblock %} {% block page_content %} -
+
{% from "erpnext/templates/includes/macros.html" import product_image %}
@@ -18,33 +19,56 @@ {% include "templates/generators/item/item_image.html" %} {% include "templates/generators/item/item_details.html" %}
- - - {% if show_tabs and tabs %} -
- - {{ web_block( - "Section with Tabs", - values=tabs, - add_container=0, - add_top_padding=0, - add_bottom_padding=0 - ) }} -
- {% elif website_specifications %} - {% include "templates/generators/item/item_specifications.html"%} - {% endif %} - - - {{ doc.website_content or '' }} - - - {% if shopping_cart.cart_settings.enable_reviews and not doc.has_variants %} - {% include "templates/generators/item/item_reviews.html"%} - {% endif %}
+ + +
+ {% set show_recommended_items = recommended_items and shopping_cart.cart_settings.enable_recommendations %} + {% set info_col = 'col-9' if show_recommended_items else 'col-12' %} + + {% set padding_top = 'pt-0' if (show_tabs and tabs) else '' %} + +
+
+
+ + {% if show_tabs and tabs %} +
+ + {{ web_block("Section with Tabs", values=tabs, add_container=0, + add_top_padding=0, add_bottom_padding=0) + }} +
+ {% elif website_specifications %} + {% include "templates/generators/item/item_specifications.html"%} + {% endif %} + + + {{ doc.website_content or '' }} + + + {% if shopping_cart.cart_settings.enable_reviews and not doc.has_variants %} + {% include "templates/generators/item/item_reviews.html"%} + {% endif %} +
+
+
+ + + {% if show_recommended_items %} + + {% endif %} + +
{% endblock %} {% block base_scripts %} diff --git a/erpnext/templates/generators/item/item_add_to_cart.html b/erpnext/templates/generators/item/item_add_to_cart.html index fd243f5059..d52168e657 100644 --- a/erpnext/templates/generators/item/item_add_to_cart.html +++ b/erpnext/templates/generators/item/item_add_to_cart.html @@ -7,34 +7,39 @@
{% if cart_settings.show_price and product_info.price %} - {% set price_info = product_info.price %} + {% set price_info = product_info.price %} - {% if price_info.formatted_mrp %} - - M.R.P.: - {{ price_info.formatted_mrp }} - - - {{ price_info.get("formatted_discount_percent") or price_info.get("formatted_discount_rate")}} OFF - - {% endif %} +
+ + {{ price_info.formatted_price_sales_uom }} -
- {{ price_info.formatted_price_sales_uom }} - ({{ price_info.formatted_price }} / {{ product_info.uom }}) -
+ + {% if price_info.formatted_mrp %} + + MRP {{ price_info.formatted_mrp }} + + + -{{ price_info.get("formatted_discount_percent") or price_info.get("formatted_discount_rate")}} + + {% endif %} + + + + ({{ price_info.formatted_price }} / {{ product_info.uom }}) + +
{% else %} {{ _("UOM") }} : {{ product_info.uom }} {% endif %} {% if cart_settings.show_stock_availability %} -
+
{% if product_info.in_stock == 0 %} {{ _('Not in stock') }} {% elif product_info.in_stock == 1 %} - + {{ _('In stock') }} {% if product_info.show_stock_qty and product_info.stock_qty %} ({{ product_info.stock_qty[0][0] }}) @@ -47,10 +52,15 @@ {% if doc.offers %}
-

Offers

+
+ + + + Available Offers +
{% for offer in doc.offers %} -
+
@@ -59,8 +69,8 @@
-

- {{ _(offer.offer_title) }}: +

+ {{ _(offer.offer_title) }}: {{ _(offer.offer_subtitle) }} -

-
+
+
{% if product_info.price and (cart_settings.allow_items_not_in_stock or product_info.in_stock) %} - - {% endif %} - - {% if cart_settings.enable_wishlist %} - - - {% set price = product_info.get("price") or {} %} - + + {% if cart_settings.show_contact_us_button %} + {% include "templates/generators/item/item_inquiry.html" %} {% endif %}
- - - {% if cart_settings.show_contact_us_button %} - {% include "templates/generators/item/item_inquiry.html" %} - {% endif %}
@@ -155,28 +129,6 @@ }); }); - $('.page_content').on('click', '.btn-add-to-wishlist', (e) => { - // Bind action on wishlist button - const $btn = $(e.currentTarget); - $btn.prop('disabled', true); - - let args = { - item_code: $btn.data('item-code'), - price: $btn.data('price'), - formatted_price: $btn.data('formatted-price') - }; - let failure_action = function() { - $btn.prop('disabled', false); - }; - let success_action = function() { - $btn.prop('disabled', false); - e_commerce.wishlist.set_wishlist_count(); - $('.btn-add-to-wishlist, .btn-view-in-wishlist').toggleClass('hidden'); - - }; - e_commerce.wishlist.add_remove_from_wishlist("add", args, success_action, failure_action); - }); - $('.page_content').on('click', '.offer-details', (e) => { // Bind action on More link in Offers const $btn = $(e.currentTarget); diff --git a/erpnext/templates/generators/item/item_details.html b/erpnext/templates/generators/item/item_details.html index cf6e2b9c19..307e0fed15 100644 --- a/erpnext/templates/generators/item/item_details.html +++ b/erpnext/templates/generators/item/item_details.html @@ -1,28 +1,65 @@ {% set width_class = "expand" if not slides else "" %} +{% set cart_settings = shopping_cart.cart_settings %} +{% set product_info = shopping_cart.product_info %} +{% set price_info = product_info.get('price') or {} %} +
- -

- {{ doc.web_item_name }} -

-

- {{ _("Item Code") }}: - {{ doc.item_code }} -

-{% if has_variants %} - - {% include "templates/generators/item/item_configure.html" %} -{% else %} - - {% include "templates/generators/item/item_add_to_cart.html" %} -{% endif %} - -
-{% if frappe.utils.strip_html(doc.web_long_description or '') %} - {{ doc.web_long_description | safe }} -{% elif frappe.utils.strip_html(doc.description or '') %} - {{ doc.description | safe }} -{% else %} - {{ _("No description given") }} -{% endif %} -
+
+ +
+ {{ doc.web_item_name }} +
+ + + {% if cart_settings.enable_wishlist %} + + {% endif %} +
+ +

+ + {{ _(doc.item_group) }} + + + {{ _("Item Code") }}: + + {{ doc.item_code }} +

+ {% if has_variants %} + + {% include "templates/generators/item/item_configure.html" %} + {% else %} + + {% include "templates/generators/item/item_add_to_cart.html" %} + {% endif %} + +
+ {% if frappe.utils.strip_html(doc.web_long_description or '') %} + {{ doc.web_long_description | safe }} + {% elif frappe.utils.strip_html(doc.description or '') %} + {{ doc.description | safe }} + {% else %} + {{ "" }} + {% endif %} +
+ +{% block base_scripts %} + + +{% endblock %} + + \ No newline at end of file diff --git a/erpnext/templates/generators/item/item_inquiry.html b/erpnext/templates/generators/item/item_inquiry.html index 72b41676e7..af636f1582 100644 --- a/erpnext/templates/generators/item/item_inquiry.html +++ b/erpnext/templates/generators/item/item_inquiry.html @@ -1,7 +1,7 @@ {% if shopping_cart and shopping_cart.cart_settings.enabled %} {% set cart_settings = shopping_cart.cart_settings %} {% if cart_settings.show_contact_us_button | int %} - {% endif %} diff --git a/erpnext/templates/generators/item/item_reviews.html b/erpnext/templates/generators/item/item_reviews.html index cd38bf3b14..508dbcebe2 100644 --- a/erpnext/templates/generators/item/item_reviews.html +++ b/erpnext/templates/generators/item/item_reviews.html @@ -1,23 +1,29 @@ {% from "erpnext/templates/includes/macros.html" import user_review, ratings_summary %} -
-
- {{ ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating) }} +
+ +
+
+ {{ _("Customer Reviews") }} +
+ +
+ + {% if frappe.session.user != "Guest" and user_is_customer %} + + {% endif %} +
+
+ + + {{ ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating, for_summary=True, total_reviews=total_reviews) }} - - {% if frappe.session.user != "Guest" and user_is_customer %} - - {% endif %} -
-
-

- {{ _("Reviews") }} -

+
{% if reviews %} {{ user_review(reviews) }} @@ -64,7 +70,7 @@ callback: function(r) { if(!r.exc) { frappe.msgprint({ - message: __("Thank you for submitting your review"), + message: __("Thank you for the review"), title: __("Review Submitted"), indicator: "green" }); diff --git a/erpnext/templates/generators/item/item_specifications.html b/erpnext/templates/generators/item/item_specifications.html index f3957610e9..4a59f83646 100644 --- a/erpnext/templates/generators/item/item_specifications.html +++ b/erpnext/templates/generators/item/item_specifications.html @@ -3,13 +3,15 @@
{% if not show_tabs %} -

Product Details

+
+ Product Details +
{% endif %} - +
{% for d in website_specifications -%} - - + + {%- endfor %}
{{ d.label }}{{ d.description }}{{ d.label }}{{ d.description }}
diff --git a/erpnext/templates/includes/macros.html b/erpnext/templates/includes/macros.html index 8413bb0eba..2863e1572d 100644 --- a/erpnext/templates/includes/macros.html +++ b/erpnext/templates/includes/macros.html @@ -7,8 +7,8 @@
{% endmacro %} -{% macro product_image(website_image, css_class="product-image", alt="") %} -
+{% macro product_image(website_image, css_class="product-image", alt="", no_border=False) %} +
{% if website_image %} {{ alt }} {% else %} @@ -208,9 +208,12 @@
{%- endmacro -%} -{%- macro ratings_with_title(avg_rating, title, size, rating_header_class) -%} -
-
+{%- macro ratings_with_title(avg_rating, title, size, rating_header_class, for_summary=False) -%} +
+

+ {{ title }} +

+
{% for i in range(1,6) %} {% set fill_class = 'star-click' if i <= avg_rating else '' %} @@ -218,44 +221,50 @@ {% endfor %}
-

- {{ title }} -

{%- endmacro -%} -{%- macro ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating)-%} - -

- {{ _("Customer Ratings") }} -

- -{% if reviews %} - {% set rating_title = frappe.utils.cstr(average_rating) + " " + _("out of 5") %} - {{ ratings_with_title(average_whole_rating, rating_title, "lg", "rating-summary-title") }} -{% endif %} - - -
- {% for percent in reviews_per_rating %} -
- {{ loop.index }} star +{%- macro ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating, for_summary=False, total_reviews=None)-%} +
+
+

+ {{ average_rating or 0 }} +

+
+ {{ frappe.utils.cstr(total_reviews) + " " + _("ratings") }}
-
-
-
-
+ + + {% if reviews %} + {% set rating_title = frappe.utils.cstr(average_rating) + " " + _("out of 5") if not for_summary else ''%} + {{ ratings_with_title(average_whole_rating, rating_title, "md", "rating-summary-title", for_summary) }} + {% endif %} + +
{{ frappe.utils.cstr(average_rating or 0) + " " + _("out of 5") }}
+
+ + +
+ {% for percent in reviews_per_rating %} +
+ {{ loop.index }} star +
+
+
+
+
+
+
+ {{ percent }}% +
-
- {{ percent }}% -
-
- {% endfor %} + {% endfor %} +
{%- endmacro -%} @@ -264,17 +273,19 @@
{% for review in reviews %}
- {{ ratings_with_title(review.rating, _(review.review_title), "md", "user-review-title") }} + {{ ratings_with_title(review.rating, _(review.review_title), "sm", "user-review-title") }} -
- {{ _(review.customer) }} - {{ review.published_on }} -
-
+

{{ _(review.comment) }}

+ +
+ {{ _(review.customer) }} + + {{ review.published_on }} +
{% endfor %}
@@ -347,3 +358,42 @@
{% endfor %} {%- endmacro -%} + +{%- macro recommended_item_row(item)-%} + +{%- endmacro -%} diff --git a/erpnext/templates/pages/customer_reviews.html b/erpnext/templates/pages/customer_reviews.html index e11da3d178..3621fcfaf9 100644 --- a/erpnext/templates/pages/customer_reviews.html +++ b/erpnext/templates/pages/customer_reviews.html @@ -4,25 +4,30 @@ {% block title %} {{ _("Customer Reviews") }} {% endblock %} {% block page_content %} -
-
-
- {{ ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating) }} +
+ +
+
+ {{ _("Customer Reviews") }} +
- - {% if frappe.session.user != "Guest" %} - - {% endif %} +
+ + {% if frappe.session.user != "Guest" and user_is_customer %} + + {% endif %} +
+ + {{ ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating, for_summary=True, total_reviews=total_reviews) }} + + -
-

- {{ _("Reviews") }} -

+
{% if reviews %} {{ user_review(reviews) }} @@ -40,7 +45,6 @@ {% endif %}
-
{% endblock %} diff --git a/erpnext/templates/pages/customer_reviews.py b/erpnext/templates/pages/customer_reviews.py index b9c8a013c7..2b8ebff3e8 100644 --- a/erpnext/templates/pages/customer_reviews.py +++ b/erpnext/templates/pages/customer_reviews.py @@ -2,6 +2,7 @@ # License: GNU General Public License v3. See license.txt import frappe from erpnext.e_commerce.doctype.item_review.item_review import get_item_reviews +from erpnext.e_commerce.doctype.website_item.website_item import check_if_user_is_customer def get_context(context): context.no_cache = 1 @@ -11,4 +12,5 @@ def get_context(context): if frappe.form_dict and frappe.form_dict.get("item_code"): context.item_code = frappe.form_dict.get("item_code") context.web_item = frappe.db.get_value("Website Item", {"item_code": context.item_code}, "name") + context.user_is_customer = check_if_user_is_customer() get_item_reviews(context.web_item, 0, 10, context)