forked from bishal-Samanta/Project-Shopclues
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paymentotp.js
60 lines (43 loc) · 1.64 KB
/
paymentotp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var payButton = document.querySelector('.payButton');
payButton.addEventListener('click',otpCheck);
var uDatabase = JSON.parse(localStorage.getItem('UserDatabase'));
function otpCheck(){
var paymentotp = document.querySelector('.otp');
var message = document.querySelector('.message');
var thanking = document.querySelector('.thanking');
if(paymentotp.value == "123456"){
message.textContent = "Payment Successful";
thanking.textContent = "Thank You For Shopping With Shopclues.";
pushData(uDatabase);
}
else{
alert("Please Enter Valid OTP");
}
}
var DataArr = JSON.parse(localStorage.getItem("mainDatabase")) || [];
var arr = [];
var cartArr = JSON.parse(localStorage.getItem("cartDatabase"));
var arr1 = [];
function pushData(uDatabase){
var message = document.querySelector('.message');
if(message.textContent = "Payment Successful"){
DataArr.push(uDatabase[0]);
localStorage.removeItem("orderDatabase");
localStorage.removeItem("UserDatabase");
localStorage.removeItem("cartDatabase");
localStorage.setItem("cartDatabase", JSON.stringify(arr));
localStorage.setItem("orderDatabase", JSON.stringify(arr1));
}
console.log(DataArr);
localStorage.setItem("mainDatabase", JSON.stringify(DataArr));
}
// var arrow = document.querySelector('.arrow');
// arrow.addEventListener('click',backTo);
// function backTo(){
// window.location.href = "payment.html";
// }
var headerImg = document.querySelector('.headerImg');
headerImg.addEventListener('click',backToProduct);
function backToProduct(){
window.location.href = "index.html";
}