Order closing
In the previous section, we saw the customer redirected to the localhost:8000/store/order
endpoint. To conclude the purchase, the customer must click on the Dispatch purchase order button. This action triggers the closeOrder
function, contained in the index.js
file:
index.js
var closeOrder = function(){
var api = $( "#api" ).attr("url") + '/0';
var target = $( "#target" ).attr("url");
$.post(api).done(function(data){
if (!data.inserted)
{
alert('purchase order has been not inserted!');
return;
}
alert('Thank you for buying in Whatstore!
Come back always!')
document.location...