[cart] add to cart, update cart

This commit is contained in:
Anand Doshi
2013-06-19 14:57:14 +05:30
parent 60035c9830
commit 3dceb8438e
9 changed files with 203 additions and 127 deletions

View File

@@ -18,15 +18,45 @@
$(document).ready(function() {
// make list of items in the cart
wn.cart.render();
wn.cart.bind_events();
// wn.cart.render();
// wn.cart.bind_events();
wn.call({
method: "website.helpers.cart.get_cart_quotation",
args: {
_type: "POST"
},
callback: function(r) {
console.log(r);
$("#cart-container").removeClass("hide");
$(".progress").remove();
if(r.exc) {
if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) {
wn.cart.show_error("Oops!", "Price List not configured.");
} else {
wn.cart.show_error("Oops!", "Something went wrong.");
}
} else {
if(r.message[0].__islocal) {
wn.cart.show_error("Empty :-(", "Go ahead and add something to your cart.");
} else {
wn.cart.render(r.message);
}
}
}
});
});
// shopping cart
if(!wn.cart) wn.cart = {};
$.extend(wn.cart, {
render: function() {
var $cart_wrapper = $("#cart-added-items").empty();
show_error: function(title, text) {
$("#cart-container").html('<div class="well"><h4>' + title + '</h4> ' + text + '</div>');
},
render: function(doclist) {
return;
var $cart_wrapper = $("#cart-items").empty();
if(Object.keys(wn.cart.get_cart()).length) {
$('<div class="row">\
<div class="col col-lg-9 col-sm-9">\