diff --git a/erpnext/e_commerce/doctype/website_item/website_item.json b/erpnext/e_commerce/doctype/website_item/website_item.json index 3b11c0f3ac..f5eb2ddb53 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.json +++ b/erpnext/e_commerce/doctype/website_item/website_item.json @@ -37,6 +37,8 @@ "display_additional_information_section", "show_tabbed_section", "tabs", + "offers_section", + "offers", "section_break_6", "ranking", "set_meta_tags", @@ -76,6 +78,7 @@ "read_only": 1 }, { + "collapsible": 1, "fieldname": "section_break_6", "fieldtype": "Section Break", "label": "Search and SEO" @@ -179,7 +182,6 @@ "read_only": 1 }, { - "fetch_from": "item_code.image", "fieldname": "image", "fieldtype": "Attach Image", "hidden": 1, @@ -286,13 +288,25 @@ "fieldname": "show_tabbed_section", "fieldtype": "Check", "label": "Add Section with Tabs" + }, + { + "collapsible": 1, + "fieldname": "offers_section", + "fieldtype": "Section Break", + "label": "Offers" + }, + { + "fieldname": "offers", + "fieldtype": "Table", + "label": "Offers to Display", + "options": "Website Offer" } ], "has_web_view": 1, "image_field": "image", "index_web_pages_for_search": 1, "links": [], - "modified": "2021-03-18 20:37:54.955364", + "modified": "2021-04-22 15:29:13.541145", "modified_by": "Administrator", "module": "E-commerce", "name": "Website Item", @@ -309,6 +323,42 @@ "role": "System Manager", "share": 1, "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Website Manager", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Stock User", + "share": 1, + "write": 1 + }, + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Stock Manager", + "share": 1, + "write": 1 } ], "search_fields": "item_code, item_name ,item_group", diff --git a/erpnext/e_commerce/doctype/website_item/website_item.py b/erpnext/e_commerce/doctype/website_item/website_item.py index 58d4f246c6..028ee76f11 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.py +++ b/erpnext/e_commerce/doctype/website_item/website_item.py @@ -138,7 +138,7 @@ class WebsiteItem(WebsiteGenerator): try: file_doc = frappe.get_doc("File", { "file_url": self.website_image, - "attached_to_doctype": "Item", + "attached_to_doctype": "Website Item", "attached_to_name": self.name }) except frappe.DoesNotExistError: @@ -161,7 +161,7 @@ class WebsiteItem(WebsiteGenerator): file_doc = frappe.get_doc({ "doctype": "File", "file_url": self.website_image, - "attached_to_doctype": "Item", + "attached_to_doctype": "Website Item", "attached_to_name": self.name }).save() diff --git a/erpnext/e_commerce/doctype/website_offer/__init__.py b/erpnext/e_commerce/doctype/website_offer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/e_commerce/doctype/website_offer/website_offer.json b/erpnext/e_commerce/doctype/website_offer/website_offer.json new file mode 100644 index 0000000000..627d548146 --- /dev/null +++ b/erpnext/e_commerce/doctype/website_offer/website_offer.json @@ -0,0 +1,43 @@ +{ + "actions": [], + "creation": "2021-04-21 13:37:14.162162", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "offer_title", + "offer_subtitle", + "offer_details" + ], + "fields": [ + { + "fieldname": "offer_title", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Offer Title" + }, + { + "fieldname": "offer_subtitle", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Offer Subtitle" + }, + { + "fieldname": "offer_details", + "fieldtype": "Text Editor", + "label": "Offer Details" + } + ], + "index_web_pages_for_search": 1, + "istable": 1, + "links": [], + "modified": "2021-04-21 13:56:04.660331", + "modified_by": "Administrator", + "module": "E-commerce", + "name": "Website Offer", + "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/website_offer/website_offer.py b/erpnext/e_commerce/doctype/website_offer/website_offer.py new file mode 100644 index 0000000000..59d580eea7 --- /dev/null +++ b/erpnext/e_commerce/doctype/website_offer/website_offer.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class WebsiteOffer(Document): + pass + +@frappe.whitelist() +def get_offer_details(offer_id): + return frappe.db.get_value('Website Offer', {'name': offer_id}, ['offer_details']) diff --git a/erpnext/public/scss/shopping_cart.scss b/erpnext/public/scss/shopping_cart.scss index d7b0cca487..04bf9838a6 100644 --- a/erpnext/public/scss/shopping_cart.scss +++ b/erpnext/public/scss/shopping_cart.scss @@ -771,3 +771,11 @@ body.product-page { margin-top: 6px; } } + +.offer-container { + border: 1px solid var(--gray-300); + border-style: dashed; + border-radius: 4px; + padding: 6px; + font-size: 14px; +} diff --git a/erpnext/templates/generators/item/item_add_to_cart.html b/erpnext/templates/generators/item/item_add_to_cart.html index 97a0480751..9d3ba3b7d4 100644 --- a/erpnext/templates/generators/item/item_add_to_cart.html +++ b/erpnext/templates/generators/item/item_add_to_cart.html @@ -44,6 +44,33 @@ {% endif %} + +
+

Offers

+
+ {% for offer in doc.offers %} +
+
+ + + + + + +
+

+ {{ _(offer.offer_title) }}: + {{ _(offer.offer_subtitle) }} + + {{ _("More") }} + +

+
+ {% endfor %} +
+
@@ -147,7 +174,42 @@ }; erpnext.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); + $btn.prop('disabled', true); + + var d = new frappe.ui.Dialog({ + title: __($btn.data('offer-title')), + fields: [ + { + fieldname: 'offer_details', + fieldtype: 'HTML' + }, + { + fieldname: 'section_break', + fieldtype: 'Section Break' + } + ] + }); + + frappe.call({ + method: 'erpnext.e_commerce.doctype.website_offer.website_offer.get_offer_details', + args: { + offer_id: $btn.data('offer-id') + }, + callback: (value) => { + d.set_value("offer_details", value.message); + d.show(); + $btn.prop('disabled', false); + } + }) + + }); }); + + {% endif %} diff --git a/erpnext/templates/generators/item/item_details.html b/erpnext/templates/generators/item/item_details.html index 95591294a0..cf6e2b9c19 100644 --- a/erpnext/templates/generators/item/item_details.html +++ b/erpnext/templates/generators/item/item_details.html @@ -2,7 +2,7 @@

- {{ item_name }} + {{ doc.web_item_name }}

{{ _("Item Code") }}: diff --git a/erpnext/templates/generators/item/item_reviews.html b/erpnext/templates/generators/item/item_reviews.html index f6b1831cda..fd03a823af 100644 --- a/erpnext/templates/generators/item/item_reviews.html +++ b/erpnext/templates/generators/item/item_reviews.html @@ -1,6 +1,6 @@ {% from "erpnext/templates/includes/macros.html" import user_review, ratings_summary %} -

+
{{ ratings_summary(reviews, reviews_per_rating, average_rating, average_whole_rating) }} diff --git a/erpnext/templates/pages/customer_reviews.html b/erpnext/templates/pages/customer_reviews.html index 9d8ba9e304..e11da3d178 100644 --- a/erpnext/templates/pages/customer_reviews.html +++ b/erpnext/templates/pages/customer_reviews.html @@ -42,4 +42,13 @@
+{% endblock %} + +{% block base_scripts %} + + + + + + {% endblock %} \ No newline at end of file