chore: Re-organise files,remove T&C modal in cart
- Moved product query and filters engine to `product_data_engine` folder
- Moved product grid, list, search, view to `product_ui` folder
- Renamed `website_item_indexing.py` to `redisearch.py`
- Render Terms and Conditions server side along with the rest of the Shopping cart. Don’t make another db call
- Style changes to terms and conditions
- Deleted unused `cart_terms.html`
- Removed print statements
diff --git a/erpnext/templates/pages/cart.html b/erpnext/templates/pages/cart.html
index 05db77a..bb8ba3b 100644
--- a/erpnext/templates/pages/cart.html
+++ b/erpnext/templates/pages/cart.html
@@ -21,8 +21,9 @@
{% if doc.items %}
<div class="cart-container">
<div class="row m-0">
- <div class="col-md-8 frappe-card p-5 mb-4">
- <div>
+ <!-- Left section -->
+ <div class="col-md-8">
+ <div class="frappe-card p-5 mb-4">
<div id="cart-error" class="alert alert-danger" style="display: none;"></div>
<div class="cart-items-header">
{{ _('Items') }}
@@ -56,61 +57,44 @@
</tfoot>
{% endif %}
</table>
- </div>
- <div class="row mt-2">
- <div class="col-3">
- {% if cart_settings.enable_checkout %}
- <a class="btn btn-primary-light font-md" href="/orders">
- {{ _('Past Orders') }}
- </a>
- {% else %}
- <a class="btn btn-primary-light font-md" href="/quotations">
- {{ _('Past Quotes') }}
- </a>
- {% endif %}
- </div>
- <div class="col-9">
- {% if doc.items %}
- <div class="place-order-container">
- <a class="btn btn-primary-light mr-2 font-md" href="/all-products">
- {{ _('Continue Shopping') }}
- </a>
+ <div class="row mt-2">
+ <div class="col-3">
+ {% if cart_settings.enable_checkout %}
+ <a class="btn btn-primary-light font-md" href="/orders">
+ {{ _('Past Orders') }}
+ </a>
+ {% else %}
+ <a class="btn btn-primary-light font-md" href="/quotations">
+ {{ _('Past Quotes') }}
+ </a>
+ {% endif %}
</div>
- {% endif %}
+ <div class="col-9">
+ {% if doc.items %}
+ <div class="place-order-container">
+ <a class="btn btn-primary-light mr-2 font-md" href="/all-products">
+ {{ _('Continue Shopping') }}
+ </a>
+ </div>
+ {% endif %}
+ </div>
</div>
</div>
-
+ <!-- Terms and Conditions -->
{% if doc.items %}
- {% if doc.tc_name %}
- <div class="terms-and-conditions-link">
- <a href class="link-terms-and-conditions" data-terms-name="{{ doc.tc_name }}">
- {{ _("Terms and Conditions") }}
- </a>
- <script>
- frappe.ready(() => {
- $('.link-terms-and-conditions').click((e) => {
- e.preventDefault();
- const $link = $(e.target);
- const terms_name = $link.attr('data-terms-name');
- show_terms_and_conditions(terms_name);
- })
- });
- function show_terms_and_conditions(terms_name) {
- frappe.call('erpnext.e_commerce.shopping_cart.cart.get_terms_and_conditions', { terms_name })
- .then(r => {
- frappe.msgprint({
- title: terms_name,
- message: r.message
- });
- });
- }
- </script>
- </div>
- {% endif %}
+ {% if doc.terms %}
+ <div class="t-and-c-container mt-4 frappe-card">
+ <h5>{{ _("Terms and Conditions") }}</h5>
+ <div class="t-and-c-terms mt-2">
+ {{ doc.terms }}
+ </div>
+ </div>
+ {% endif %}
</div>
+ <!-- Right section -->
<div class="col-md-4">
<div class="cart-payment-addresses">
<!-- Apply Coupon Code -->
diff --git a/erpnext/templates/pages/cart_terms.html b/erpnext/templates/pages/cart_terms.html
deleted file mode 100644
index 6d84fb8..0000000
--- a/erpnext/templates/pages/cart_terms.html
+++ /dev/null
@@ -1,2 +0,0 @@
-
-<div>{{doc.terms}}</div>
diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py
index b6601a8..00aace4 100644
--- a/erpnext/templates/pages/product_search.py
+++ b/erpnext/templates/pages/product_search.py
@@ -8,7 +8,7 @@
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,
@@ -18,7 +18,6 @@
no_cache = 1
-
def get_context(context):
context.show_search = True
@@ -35,13 +34,13 @@
# 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
@@ -53,7 +52,7 @@
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
@@ -91,14 +90,9 @@
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):