From 220ff30878c7581237db9fa89141944825134449 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 14 May 2013 15:33:34 +0530 Subject: [PATCH] [website] [product] show currency symbol and show specifications below the image --- website/helpers/product.py | 19 ++++++++++++++----- website/templates/css/product_page.css | 3 +++ website/templates/html/product_page.html | 18 ++++++++++-------- website/templates/js/product_page.js | 4 ++-- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/website/helpers/product.py b/website/helpers/product.py index d6f16fb753..a107d9b02b 100644 --- a/website/helpers/product.py +++ b/website/helpers/product.py @@ -4,10 +4,9 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cstr +from webnotes.utils import cstr, cint from webnotes.webutils import build_html, delete_page_cache - @webnotes.whitelist(allow_guest=True) def get_product_info(item_code): """get product price / stock info""" @@ -20,10 +19,20 @@ def get_product_info(item_code): in_stock = in_stock[0][0] > 0 and 1 or 0 else: in_stock = -1 + + price = price_list and webnotes.conn.sql("""select ref_rate, ref_currency from + `tabItem Price` where parent=%s and price_list_name=%s""", + (item_code, price_list), as_dict=1) or [] + + price = price and price[0] or None + + if price: + price["ref_currency"] = not cint(webnotes.conn.get_default("hide_currency_symbol")) \ + and (webnotes.conn.get_value("Currency", price.ref_currency, "symbol") or price.ref_currency) \ + or "" + return { - "price": price_list and webnotes.conn.sql("""select ref_rate, ref_currency from - `tabItem Price` where parent=%s and price_list_name=%s""", - (item_code, price_list), as_dict=1) or [], + "price": price, "stock": in_stock } diff --git a/website/templates/css/product_page.css b/website/templates/css/product_page.css index 566b6b57aa..71be9ee56b 100644 --- a/website/templates/css/product_page.css +++ b/website/templates/css/product_page.css @@ -7,4 +7,7 @@ font-size: 18px; line-height: 200%; } + .item-price { + margin-top: 20px; + } \ No newline at end of file diff --git a/website/templates/html/product_page.html b/website/templates/html/product_page.html index 23091ad435..3fda8cd271 100644 --- a/website/templates/html/product_page.html +++ b/website/templates/html/product_page.html @@ -35,23 +35,25 @@ {{ web_long_description or web_short_description or "[No description given]" }} - {% if obj.doclist.get({"doctype":"Item Website Specification"}) %} +
+
+ + + {% if obj.doclist.get({"doctype":"Item Website Specification"}) -%} +
+

Specifications

{% for d in obj.doclist.get( - {"doctype":"Item Website Specification"}) %} + {"doctype":"Item Website Specification"}) -%} - {% endfor %} + {%- endfor %}
{{ d.label }} {{ d.description }}
- {% endif %} -
-

Price:

-
-
+ {%- endif %} {% endblock %} \ No newline at end of file diff --git a/website/templates/js/product_page.js b/website/templates/js/product_page.js index 653cfa3239..69e9cd52fe 100644 --- a/website/templates/js/product_page.js +++ b/website/templates/js/product_page.js @@ -26,8 +26,8 @@ $(document).ready(function() { success: function(data) { if(data.message) { if(data.message.price) { - $("

").html(data.message.price[0].ref_currency + " " - + data.message.price[0].ref_rate).appendTo(".item-price"); + $("

").html(data.message.price.ref_currency + " " + + data.message.price.ref_rate).appendTo(".item-price"); $(".item-price").toggle(true); } if(data.message.stock==0) {