[webshop] Place Order - submits Quotation, creates Customer if required, creates and submits Sales Order
diff --git a/website/templates/html/outer.html b/website/templates/html/outer.html
index cc1181c..0102acd 100644
--- a/website/templates/html/outer.html
+++ b/website/templates/html/outer.html
@@ -10,8 +10,10 @@
<div class="pull-right hide" style="margin:4px;" id="user-tools-post-login">
<a href="profile" title="My Profile" id="user-full-name"></a> |
<a href="account" title="My Account">My Account</a> |
+ {% if shopping_cart_enabled -%}
<a href="cart" title="Shopping Cart"><i class="icon-shopping-cart"></i>
<span class="cart-count"></span></a> |
+ {%- endif %}
<a href="server.py?cmd=web_logout" title="Sign Out"><i class="icon-signout"></i></a>
</div>
<div class="clearfix"></div>
diff --git a/website/templates/html/product_page.html b/website/templates/html/product_page.html
index b3e8be2..73520ef 100644
--- a/website/templates/html/product_page.html
+++ b/website/templates/html/product_page.html
@@ -32,7 +32,7 @@
<p class="help">Item Code: <span itemprop="productID">{{ name }}</span></p>
<h4>Product Description</h4>
<div itemprop="description">
- {{ web_long_description or web_short_description or
+ {{ web_long_description or web_short_description or description or
"[No description given]" }}
</div>
<div style="min-height: 100px; margin: 10px 0;">
diff --git a/website/templates/js/cart.js b/website/templates/js/cart.js
index 27f604f..bb3fcb9 100644
--- a/website/templates/js/cart.js
+++ b/website/templates/js/cart.js
@@ -17,8 +17,6 @@
// js inside blog page
$(document).ready(function() {
- // make list of items in the cart
- // wn.cart.render();
wn.cart.bind_events();
wn.call({
type: "POST",
@@ -36,6 +34,7 @@
wn.cart.show_error("Oops!", "Something went wrong.");
}
} else {
+ wn.cart.set_cart_count();
wn.cart.render(r.message);
}
}
@@ -75,6 +74,10 @@
$("#cart-add-billing-address").on("click", function() {
window.location.href = "address?address_fieldname=customer_address";
});
+
+ $(".btn-place-order").on("click", function() {
+ wn.cart.place_order();
+ });
},
render: function(out) {
@@ -282,5 +285,27 @@
$address_wrapper.find('.accordion-body[data-address-name="'+ address_name +'"]')
.collapse("show");
+ },
+
+ place_order: function() {
+ wn.call({
+ type: "POST",
+ method: "website.helpers.cart.place_order",
+ callback: function(r) {
+ if(r.exc) {
+ var msg = "";
+ if(r._server_messages) {
+ msg = JSON.parse(r._server_messages || []).join("<br>");
+ }
+
+ $("#cart-error")
+ .empty()
+ .html(msg || "Something went wrong!")
+ .toggle(true);
+ } else {
+ window.location.href = "order?name=" + encodeURIComponent(r.message);
+ }
+ }
+ });
}
});
\ No newline at end of file
diff --git a/website/templates/pages/address.html b/website/templates/pages/address.html
index 5b90928..cf1fc4b 100644
--- a/website/templates/pages/address.html
+++ b/website/templates/pages/address.html
@@ -112,12 +112,4 @@
};
})();
</script>
-{% endblock %}
-
-{% block css %}
-<style>
-fieldset {
- margin-bottom: 20px;
-}
-</style>
{% endblock %}
\ No newline at end of file
diff --git a/website/templates/pages/cart.html b/website/templates/pages/cart.html
index cefcb5a..5bfca33 100644
--- a/website/templates/pages/cart.html
+++ b/website/templates/pages/cart.html
@@ -13,8 +13,9 @@
<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
</div>
<div id="cart-container" class="hide">
- <button class="btn btn-success pull-right" type="button">Place Order</button>
+ <button class="btn btn-success pull-right btn-place-order" type="button">Place Order</button>
<div class="clearfix"></div>
+ <div id="cart-error" class="alert alert-danger" style="display: none;"></div>
<hr>
<div class="row">
<div class="col col-lg-9 col-sm-9">
@@ -50,7 +51,7 @@
</div>
<hr>
</div>
- <button class="btn btn-success pull-right" type="button">Place Order</button>
+ <button class="btn btn-success pull-right btn-place-order" type="button">Place Order</button>
</div>
</div>
{% endblock %}
\ No newline at end of file
diff --git a/website/templates/pages/profile.html b/website/templates/pages/profile.html
index 993839e..61ae1b0 100644
--- a/website/templates/pages/profile.html
+++ b/website/templates/pages/profile.html
@@ -12,24 +12,28 @@
<h2><i class="icon-user"></i> My Profile</h2>
<hr>
<div class="alert" id="message" style="display: none;"></div>
- <form class="form-horizontal">
- <div class="control-group">
- <label class="control-label" for="fullname">Full Name</label>
- <div class="controls">
- <input type="text" id="fullname" placeholder="Your Name">
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="password">Password</label>
- <div class="controls">
- <input type="password" id="password" placeholder="Password">
- </div>
- </div>
- <div class="control-group">
- <div class="controls">
- <button id="update_profile" type="submit" class="btn btn-default">Update</button>
- </div>
- </div>
+ <form>
+ <fieldset>
+ <label>Full Name</label>
+ <input type="text" id="fullname" placeholder="Your Name">
+ </fieldset>
+ <fieldset>
+ <label>Password</label>
+ <input type="password" id="password" placeholder="Password">
+ </fieldset>
+ <fieldset>
+ <label>Company Name</label>
+ <input type="text" id="company_name" placeholder="Company Name" value="{{ company_name }}">
+ </fieldset>
+ <fieldset>
+ <label>Mobile No</label>
+ <input type="text" id="mobile_no" placeholder="Mobile No" value="{{ mobile_no }}">
+ </fieldset>
+ <fieldset>
+ <label>Phone</label>
+ <input type="text" id="phone" placeholder="Phone" value="{{ phone }}">
+ </fieldset>
+ <button id="update_profile" type="submit" class="btn btn-default">Update</button>
</form>
</div>
<script>
@@ -37,11 +41,14 @@
$("#fullname").val(getCookie("full_name") || "");
$("#update_profile").click(function() {
wn.call({
- method: "core.doctype.profile.profile.update_profile",
+ method: "startup.webutils.update_profile",
type: "POST",
args: {
fullname: $("#fullname").val(),
- password: $("#password").val()
+ password: $("#password").val(),
+ company_name: $("#company_name").val(),
+ mobile_no: $("#mobile_no").val(),
+ phone: $("#phone").val()
},
btn: this,
msg: $("#message"),
@@ -53,4 +60,4 @@
})
})
</script>
-{% endblock %}
+{% endblock %}
\ No newline at end of file