diff --git a/erpnext/e_commerce/api.py b/erpnext/e_commerce/api.py index 4f83f08ae71..4c9f4a79c6a 100644 --- a/erpnext/e_commerce/api.py +++ b/erpnext/e_commerce/api.py @@ -5,8 +5,8 @@ import frappe from frappe.utils import cint -from erpnext.e_commerce.product_query import ProductQuery -from erpnext.e_commerce.filters import ProductFiltersBuilder +from erpnext.e_commerce.product_data_engine.query import ProductQuery +from erpnext.e_commerce.product_data_engine.filters import ProductFiltersBuilder from erpnext.setup.doctype.item_group.item_group import get_child_groups @frappe.whitelist(allow_guest=True) diff --git a/erpnext/e_commerce/doctype/e_commerce_settings/e_commerce_settings.py b/erpnext/e_commerce/doctype/e_commerce_settings/e_commerce_settings.py index 0959e3e5a16..9f6f5df518f 100644 --- a/erpnext/e_commerce/doctype/e_commerce_settings/e_commerce_settings.py +++ b/erpnext/e_commerce/doctype/e_commerce_settings/e_commerce_settings.py @@ -8,7 +8,7 @@ from frappe.utils import cint, comma_and from frappe import _, msgprint from frappe.model.document import Document from frappe.utils import unique -from erpnext.e_commerce.website_item_indexing import create_website_items_index, ALLOWED_INDEXABLE_FIELDS_SET, is_search_module_loaded +from erpnext.e_commerce.redisearch import create_website_items_index, ALLOWED_INDEXABLE_FIELDS_SET, is_search_module_loaded class ShoppingCartSetupError(frappe.ValidationError): pass diff --git a/erpnext/e_commerce/doctype/website_item/website_item.py b/erpnext/e_commerce/doctype/website_item/website_item.py index 7d375ada3c7..36ed8bf4e47 100644 --- a/erpnext/e_commerce/doctype/website_item/website_item.py +++ b/erpnext/e_commerce/doctype/website_item/website_item.py @@ -17,7 +17,7 @@ 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 ( +from erpnext.e_commerce.redisearch import ( insert_item_to_index, update_index_for_item, delete_item_from_index diff --git a/erpnext/e_commerce/shopping_cart/search.py b/erpnext/e_commerce/legacy_search.py similarity index 99% rename from erpnext/e_commerce/shopping_cart/search.py rename to erpnext/e_commerce/legacy_search.py index 2ed57f0c27d..27fd6e89cd8 100644 --- a/erpnext/e_commerce/shopping_cart/search.py +++ b/erpnext/e_commerce/legacy_search.py @@ -6,6 +6,7 @@ from whoosh.qparser import MultifieldParser, FieldsPlugin, WildcardPlugin from whoosh.analysis import StemmingAnalyzer from whoosh.query import Prefix +# TODO: Make obsolete INDEX_NAME = "products" class ProductSearch(FullTextSearch): diff --git a/erpnext/e_commerce/product_configurator/test_product_configurator.py b/erpnext/e_commerce/product_configurator/test_product_configurator.py index 234a21be60e..48dc90355dd 100644 --- a/erpnext/e_commerce/product_configurator/test_product_configurator.py +++ b/erpnext/e_commerce/product_configurator/test_product_configurator.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals from bs4 import BeautifulSoup import frappe, unittest from frappe.utils import get_html_for_route -from erpnext.e_commerce.product_query import ProductQuery +from erpnext.e_commerce.product_data_engine.query import ProductQuery from erpnext.e_commerce.doctype.website_item.website_item import make_website_item test_dependencies = ["Item"] diff --git a/erpnext/e_commerce/filters.py b/erpnext/e_commerce/product_data_engine/filters.py similarity index 96% rename from erpnext/e_commerce/filters.py rename to erpnext/e_commerce/product_data_engine/filters.py index 5589e1290e4..b9596231f7a 100644 --- a/erpnext/e_commerce/filters.py +++ b/erpnext/e_commerce/product_data_engine/filters.py @@ -1,7 +1,5 @@ -# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals import frappe from frappe import _dict from frappe.utils import floor diff --git a/erpnext/e_commerce/product_query.py b/erpnext/e_commerce/product_data_engine/query.py similarity index 99% rename from erpnext/e_commerce/product_query.py rename to erpnext/e_commerce/product_data_engine/query.py index d29e17870ab..93d230a7fbb 100644 --- a/erpnext/e_commerce/product_query.py +++ b/erpnext/e_commerce/product_data_engine/query.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors +# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt import frappe diff --git a/erpnext/e_commerce/product_grid.js b/erpnext/e_commerce/product_ui/grid.js similarity index 100% rename from erpnext/e_commerce/product_grid.js rename to erpnext/e_commerce/product_ui/grid.js diff --git a/erpnext/e_commerce/product_list.js b/erpnext/e_commerce/product_ui/list.js similarity index 100% rename from erpnext/e_commerce/product_list.js rename to erpnext/e_commerce/product_ui/list.js diff --git a/erpnext/e_commerce/product_search.js b/erpnext/e_commerce/product_ui/search.js similarity index 97% rename from erpnext/e_commerce/product_search.js rename to erpnext/e_commerce/product_ui/search.js index ebe007624a0..b93c9759280 100644 --- a/erpnext/e_commerce/product_search.js +++ b/erpnext/e_commerce/product_ui/search.js @@ -49,7 +49,7 @@ erpnext.ProductSearch = class { // Fetch and populate product results frappe.call({ - method: "erpnext.templates.pages.product_search.search", + method: "erpnext.templates.pages.e_commerce.product_search.search", args: { query: query }, @@ -61,7 +61,7 @@ erpnext.ProductSearch = class { // Populate categories if (me.category_container) { frappe.call({ - method: "erpnext.templates.pages.product_search.get_category_suggestions", + method: "erpnext.templates.pages.e_commerce.product_search.get_category_suggestions", args: { query: query }, diff --git a/erpnext/e_commerce/product_view.js b/erpnext/e_commerce/product_ui/views.js similarity index 100% rename from erpnext/e_commerce/product_view.js rename to erpnext/e_commerce/product_ui/views.js diff --git a/erpnext/e_commerce/website_item_indexing.py b/erpnext/e_commerce/redisearch.py similarity index 100% rename from erpnext/e_commerce/website_item_indexing.py rename to erpnext/e_commerce/redisearch.py diff --git a/erpnext/public/build.json b/erpnext/public/build.json index 85a75e38b33..8e83f8bd815 100644 --- a/erpnext/public/build.json +++ b/erpnext/public/build.json @@ -69,9 +69,9 @@ "public/js/bank_reconciliation_tool/dialog_manager.js" ], "js/e-commerce.min.js": [ - "e_commerce/product_view.js", - "e_commerce/product_grid.js", - "e_commerce/product_list.js", - "e_commerce/product_search.js" + "e_commerce/product_ui/views.js", + "e_commerce/product_ui/grid.js", + "e_commerce/product_ui/list.js", + "e_commerce/product_ui/search.js" ] } diff --git a/erpnext/public/scss/shopping_cart.scss b/erpnext/public/scss/shopping_cart.scss index 80b1e5c8020..e4988f4351b 100644 --- a/erpnext/public/scss/shopping_cart.scss +++ b/erpnext/public/scss/shopping_cart.scss @@ -834,6 +834,14 @@ body.product-page { } } } + + .t-and-c-container { + padding: 1.5rem; + } + + .t-and-c-terms { + font-size: 14px; + } } .cart-empty.frappe-card { diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 3bdc56dfe29..7dd8c7c9db5 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -11,7 +11,7 @@ from frappe.website.website_generator import WebsiteGenerator from frappe.website.render import clear_cache from frappe.website.doctype.website_slideshow.website_slideshow import get_slideshow from six.moves.urllib.parse import quote -from erpnext.e_commerce.filters import ProductFiltersBuilder +from erpnext.e_commerce.product_data_engine.filters import ProductFiltersBuilder class ItemGroup(NestedSet, WebsiteGenerator): nsm_parent_field = 'parent_item_group' diff --git a/erpnext/templates/pages/cart.html b/erpnext/templates/pages/cart.html index cc5be2bf147..a0aef90461c 100644 --- a/erpnext/templates/pages/cart.html +++ b/erpnext/templates/pages/cart.html @@ -21,8 +21,9 @@ {% if doc.items %}
-
-
+ +
+
{{ _('Items') }} @@ -56,61 +57,44 @@ {% endif %} -
-
-
- {% if cart_settings.enable_checkout %} - - {{ _('Past Orders') }} - - {% else %} - - {{ _('Past Quotes') }} - - {% endif %} -
-
- {% if doc.items %} -
- - {{ _('Continue Shopping') }} - +
+
+ {% if cart_settings.enable_checkout %} + + {{ _('Past Orders') }} + + {% else %} + + {{ _('Past Quotes') }} + + {% endif %} +
+
+ {% if doc.items %} + + {% endif %}
- {% endif %}
- + {% if doc.items %} - {% if doc.tc_name %} - - {% endif %} + {% if doc.terms %} +
+
{{ _("Terms and Conditions") }}
+
+ {{ doc.terms }} +
+
+ {% endif %}
+
diff --git a/erpnext/templates/pages/cart_terms.html b/erpnext/templates/pages/cart_terms.html deleted file mode 100644 index 521c583cb60..00000000000 --- a/erpnext/templates/pages/cart_terms.html +++ /dev/null @@ -1,2 +0,0 @@ - -
{{doc.terms}}
\ No newline at end of file diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py index f387fbfad70..b8dd225f688 100644 --- a/erpnext/templates/pages/product_search.py +++ b/erpnext/templates/pages/product_search.py @@ -7,7 +7,7 @@ from erpnext.setup.doctype.item_group.item_group import get_item_for_list_in_htm from erpnext.e_commerce.shopping_cart.product_info import set_product_info_for_website from redisearch import AutoCompleter, Client, Query -from erpnext.e_commerce.website_item_indexing import ( +from erpnext.e_commerce.redisearch import ( is_search_module_loaded, WEBSITE_ITEM_INDEX, WEBSITE_ITEM_NAME_AUTOCOMPLETE, @@ -17,7 +17,6 @@ from erpnext.e_commerce.website_item_indexing import ( no_cache = 1 - def get_context(context): context.show_search = True @@ -34,13 +33,13 @@ def get_product_data(search=None, start=0, limit=12): # limit = 12 because we show 12 items in the grid view # base query query = """ - Select + SELECT web_item_name, item_name, item_code, brand, route, website_image, thumbnail, item_group, description, web_long_description as website_description, website_warehouse, ranking - from `tabWebsite Item` - where published = 1 + FROM `tabWebsite Item` + WHERE published = 1 """ # search term condition @@ -52,7 +51,7 @@ def get_product_data(search=None, start=0, limit=12): search = "%" + cstr(search) + "%" # order by - query += """ order by ranking asc, modified desc limit %s, %s""" % (cint(start), cint(limit)) + query += """ ORDER BY ranking asc, modified desc limit %s, %s""" % (cint(start), cint(limit)) return frappe.db.sql(query, { "search": search @@ -90,14 +89,9 @@ def search(query, limit=10, fuzzy_search=True): q = Query(query_string) - print(f"Executing query: {q.query_string()}") - results = client.search(q) search_results['results'] = list(map(convert_to_dict, results.docs)) - # FOR DEBUGGING - print("SEARCH RESULTS ------------------\n ", search_results) - return search_results def clean_up_query(query): diff --git a/erpnext/www/all-products/index.py b/erpnext/www/all-products/index.py index a5476e4a620..c66924e3a97 100644 --- a/erpnext/www/all-products/index.py +++ b/erpnext/www/all-products/index.py @@ -1,6 +1,6 @@ import frappe from frappe.utils import cint -from erpnext.e_commerce.filters import ProductFiltersBuilder +from erpnext.e_commerce.product_data_engine.filters import ProductFiltersBuilder sitemap = 1