blob: 8746dd6d5ab19c889f90bf41794865257b382bfd [file] [log] [blame]
Anand Doshiab690292013-06-13 11:21:35 +05301// ERPNext - web based ERP (http://erpnext.com)
2// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17// js inside blog page
18
19$(document).ready(function() {
20 // make list of items in the cart
21 wn.cart.render();
22});
23
24// shopping cart
25if(!wn.cart) wn.cart = {};
26$.extend(wn.cart, {
27 render: function() {
28 var $cart_wrapper = $("#cart-added-items").empty();
29 if(Object.keys(wn.cart.get_cart()).length) {
30 $('<div class="row">\
31 <div class="col col-lg-10 col-sm-10">\
32 <div class="row">\
33 <div class="col col-lg-3"></div>\
34 <div class="col col-lg-9"><strong>Item Details</strong></div>\
35 </div>\
36 </div>\
37 <div class="col col-lg-2 col-sm-2"><strong>Qty</strong></div>\
38 </div><hr>').appendTo($cart_wrapper);
39
40 $.each(wn.cart.get_cart(), function(item_code, item) {
41 item.image_html = item.image ?
42 '<div style="height: 120px; overflow: hidden;"><img src="' + item.image + '" /></div>' :
43 '{% include "app/website/templates/html/product_missing_image.html" %}';
44 item.price_html = item.price ? ('<p>@ ' + item.price + '</p>') : "";
45
46 $(repl('<div class="row">\
47 <div class="col col-lg-10 col-sm-10">\
48 <div class="row">\
49 <div class="col col-lg-3">%(image_html)s</div>\
50 <div class="col col-lg-9">\
51 <h4><a href="%(url)s">%(item_name)s</a></h4>\
52 <p>%(description)s</p>\
53 </div>\
54 </div>\
55 </div>\
56 <div class="col col-lg-2 col-sm-2">\
57 <input type="text" placeholder="Qty" value="%(qty)s">\
58 %(price_html)s\
59 </div>\
60 </div><hr>', item)).appendTo($cart_wrapper);
61 });
62 } else {
63 $('<p class="alert">No Items added to cart.</p>').appendTo($cart_wrapper);
64 }
65 }
66});