diff --git a/public/js/checkout.js b/public/js/checkout.js new file mode 100644 index 0000000..a48b4d3 --- /dev/null +++ b/public/js/checkout.js @@ -0,0 +1,40 @@ +function view_checkout() { + var bag = JSON.parse(localStorage.getItem("bag")); + var html = ''; + var total_price = 0; + + for (var i = 0; i < bag.length; i++) { + let request = new XMLHttpRequest(); + request.open('GET', `api/getProduct?id=${bag[i].product_id}`, false); + request.send(null); + + if (request.status === 200) { + let data = JSON.parse(request.responseText); + total_price += parseInt(data[0].PRICE * bag[i].quantity); + html += ` +
${data[0].TITLE}
+${data[0].SIZE}
+Qty : ${bag[i].quantity}
+