[cart] create quotation on checkout

This commit is contained in:
Anand Doshi
2013-06-14 17:44:03 +05:30
parent 37982a6a1f
commit abc100302c
17 changed files with 306 additions and 59 deletions

View File

@@ -19,6 +19,7 @@
$(document).ready(function() {
// make list of items in the cart
wn.cart.render();
wn.cart.bind_events();
});
// shopping cart
@@ -28,23 +29,23 @@ $.extend(wn.cart, {
var $cart_wrapper = $("#cart-added-items").empty();
if(Object.keys(wn.cart.get_cart()).length) {
$('<div class="row">\
<div class="col col-lg-10 col-sm-10">\
<div class="col col-lg-9 col-sm-9">\
<div class="row">\
<div class="col col-lg-3"></div>\
<div class="col col-lg-9"><strong>Item Details</strong></div>\
</div>\
</div>\
<div class="col col-lg-2 col-sm-2"><strong>Qty</strong></div>\
<div class="col col-lg-3 col-sm-3"><strong>Qty</strong></div>\
</div><hr>').appendTo($cart_wrapper);
$.each(wn.cart.get_cart(), function(item_code, item) {
item.image_html = item.image ?
'<div style="height: 120px; overflow: hidden;"><img src="' + item.image + '" /></div>' :
'{% include "app/website/templates/html/product_missing_image.html" %}';
item.price_html = item.price ? ('<p>@ ' + item.price + '</p>') : "";
item.price_html = item.price ? ('<p>at ' + item.price + '</p>') : "";
$(repl('<div class="row">\
<div class="col col-lg-10 col-sm-10">\
<div class="col col-lg-9 col-sm-9">\
<div class="row">\
<div class="col col-lg-3">%(image_html)s</div>\
<div class="col col-lg-9">\
@@ -53,14 +54,47 @@ $.extend(wn.cart, {
</div>\
</div>\
</div>\
<div class="col col-lg-2 col-sm-2">\
<input type="text" placeholder="Qty" value="%(qty)s">\
<div class="col col-lg-3 col-sm-3">\
<p><input type="text" placeholder="Qty" value="%(qty)s" \
item_code="%(item_code)s" class="cart-input-qty"></p>\
%(price_html)s\
</div>\
</div><hr>', item)).appendTo($cart_wrapper);
});
$('<p class="text-right"><button type="button" class="btn btn-success checkout-btn">\
<span class="icon-ok"></span> Checkout</button></p>')
.appendTo($cart_wrapper);
} else {
$('<p class="alert">No Items added to cart.</p>').appendTo($cart_wrapper);
}
},
bind_events: function() {
// on change of qty
$(".cart-input-qty").on("change", function on_change_of_qty() {
wn.cart.set_value_in_cart($(this).attr("item_code"), "qty", $(this).val());
});
// shopping cart button
$(".checkout-btn").on("click", function() {
console.log("checkout!");
console.log(wn.cart.get_cart());
var user_is_logged_in = getCookie("full_name");
if(user_is_logged_in) {
wn.call({
method: "website.helpers.cart.checkout",
args: {cart: wn.cart.get_cart()},
btn: this,
callback: function(r) {
console.log(r);
}
});
} else {
window.location.href = "login?from=cart";
}
});
}
});

View File

@@ -26,8 +26,9 @@ $(document).ready(function() {
success: function(data) {
if(data.message) {
if(data.message.price) {
$("<h4>").html(data.message.price.ref_currency + " "
+ data.message.price.ref_rate).appendTo(".item-price");
$("<h4>")
.html(data.message.price.formatted_price + " per " + data.message.uom)
.appendTo(".item-price");
$(".item-price").removeClass("hide");
}
if(data.message.stock==0) {

View File

@@ -4,7 +4,7 @@
{% block content %}
<div class="col col-lg-12">
<h2 id="blog-title">Sales Partners</h2>
<h2 id="blog-title">Partners</h2>
<hr>
{% for partner_info in partners %}
<div class="row">