| 12694 |
anikendra |
1 |
function shippingform(){
|
|
|
2 |
|
|
|
3 |
var fname = document.getElementById("name").value;
|
|
|
4 |
var street1 = document.getElementById("line1").value;
|
|
|
5 |
var street2 = document.getElementById("line2").value;
|
|
|
6 |
var city = document.getElementById("city").value;
|
|
|
7 |
var state = document.getElementById("state");
|
|
|
8 |
state = state.options[state.selectedIndex].text;
|
|
|
9 |
var zipcode = document.getElementById("pin").value;
|
|
|
10 |
var phone = document.getElementById("phone").value;
|
|
|
11 |
if(fname =='')
|
|
|
12 |
{
|
|
|
13 |
document.getElementById('error').style.display = "block";
|
|
|
14 |
document.getElementById('error').innerHTML ='Please fill name field!';
|
|
|
15 |
window.scrollTo(0,0); return false;}
|
|
|
16 |
if(!removeScript(fname))
|
|
|
17 |
{
|
|
|
18 |
document.getElementById('error').style.display = "block";
|
|
|
19 |
document.getElementById('error').innerHTML ='Please remove script tags!';
|
|
|
20 |
window.scrollTo(0,0); return false;}
|
|
|
21 |
if(fname.length> 50)
|
|
|
22 |
{
|
|
|
23 |
document.getElementById('error').style.display = "block";
|
|
|
24 |
document.getElementById('error').innerHTML ='Please Enter Less Than 50 Characters in name field!';
|
|
|
25 |
window.scrollTo(0,0); return false;}
|
|
|
26 |
if(fname !== fname.trim())
|
|
|
27 |
{
|
|
|
28 |
document.getElementById('error').style.display = "block";
|
|
|
29 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from name field!';
|
|
|
30 |
window.scrollTo(0,0); return false;}
|
|
|
31 |
if(fname !== fname.replace(/\s+/g, ' '))
|
|
|
32 |
{
|
|
|
33 |
document.getElementById('error').style.display = "block";
|
|
|
34 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from name field!';
|
|
|
35 |
window.scrollTo(0,0); return false;}
|
|
|
36 |
if(street1 =='')
|
|
|
37 |
{
|
|
|
38 |
document.getElementById('error').style.display = "block";
|
|
|
39 |
document.getElementById('error').innerHTML ='Please fill address field!';
|
|
|
40 |
window.scrollTo(0,0); return false;}
|
|
|
41 |
if(street1 != street1.trim())
|
|
|
42 |
{
|
|
|
43 |
document.getElementById('error').style.display = "block";
|
|
|
44 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
|
|
|
45 |
window.scrollTo(0,0); return false;}
|
|
|
46 |
if(street1 != street1.replace(/\s+/g, ' '))
|
|
|
47 |
{
|
|
|
48 |
document.getElementById('error').style.display = "block";
|
|
|
49 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
|
|
|
50 |
window.scrollTo(0,0); return false;}
|
|
|
51 |
if(!removeScript(street1))
|
|
|
52 |
{
|
|
|
53 |
document.getElementById('error').style.display = "block";
|
|
|
54 |
document.getElementById('error').innerHTML ='Please remove script tags!';
|
|
|
55 |
window.scrollTo(0,0); return false;}
|
|
|
56 |
if(street2 != street2.trim())
|
|
|
57 |
{
|
|
|
58 |
document.getElementById('error').style.display = "block";
|
|
|
59 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
|
|
|
60 |
window.scrollTo(0,0); return false;}
|
|
|
61 |
if(street2 != street2.replace(/\s+/g, ' '))
|
|
|
62 |
{
|
|
|
63 |
document.getElementById('error').style.display = "block";
|
|
|
64 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from address field!';
|
|
|
65 |
window.scrollTo(0,0); return false;}
|
|
|
66 |
if(!removeScript(street2))
|
|
|
67 |
{
|
|
|
68 |
document.getElementById('error').style.display = "block";
|
|
|
69 |
document.getElementById('error').innerHTML ='Please remove script tags!';
|
|
|
70 |
window.scrollTo(0,0); return false;}
|
|
|
71 |
if(state =='Select State' || state == ' ')
|
|
|
72 |
{
|
|
|
73 |
document.getElementById('error').style.display = "block";
|
|
|
74 |
document.getElementById('error').innerHTML ='Please fill state field!';
|
|
|
75 |
window.scrollTo(0,0); return false;}
|
|
|
76 |
if(!removeScript(state))
|
|
|
77 |
{
|
|
|
78 |
document.getElementById('error').style.display = "block";
|
|
|
79 |
document.getElementById('error').innerHTML ='Please remove script tags!';
|
|
|
80 |
window.scrollTo(0,0); return false;}
|
|
|
81 |
if(city =='')
|
|
|
82 |
{
|
|
|
83 |
document.getElementById('error').style.display = "block";
|
|
|
84 |
document.getElementById('error').innerHTML ='Please fill City field!';
|
|
|
85 |
window.scrollTo(0,0); return false;}
|
|
|
86 |
if(!removeScript(city))
|
|
|
87 |
{
|
|
|
88 |
document.getElementById('error').style.display = "block";
|
|
|
89 |
document.getElementById('error').innerHTML ='Please remove script tags!';
|
|
|
90 |
window.scrollTo(0,0); return false;}
|
|
|
91 |
if(city != city.trim())
|
|
|
92 |
{
|
|
|
93 |
document.getElementById('error').style.display = "block";
|
|
|
94 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from city!';
|
|
|
95 |
window.scrollTo(0,0); return false;}
|
|
|
96 |
if(city != city.replace(/\s+/g, ' '))
|
|
|
97 |
{
|
|
|
98 |
document.getElementById('error').style.display = "block";
|
|
|
99 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from city!';
|
|
|
100 |
window.scrollTo(0,0); return false;}
|
|
|
101 |
if(zipcode =='')
|
|
|
102 |
{
|
|
|
103 |
document.getElementById('error').style.display = "block";
|
|
|
104 |
document.getElementById('error').innerHTML ='Please fill pincode field!';
|
|
|
105 |
window.scrollTo(0,0); return false;}
|
|
|
106 |
if(zipcode.length !=6)
|
|
|
107 |
{
|
|
|
108 |
document.getElementById('error').style.display = "block";
|
|
|
109 |
document.getElementById('error').innerHTML ='Pincode should be 6 digits long';
|
|
|
110 |
window.scrollTo(0,0); return false;}
|
|
|
111 |
if(!/^\d+$/.test(zipcode))
|
|
|
112 |
{
|
|
|
113 |
document.getElementById('error').style.display = "block";
|
|
|
114 |
document.getElementById('error').innerHTML ='Please Use numbers only for pincode!';
|
|
|
115 |
window.scrollTo(0,0); return false;}
|
|
|
116 |
if(zipcode != zipcode.trim())
|
|
|
117 |
{
|
|
|
118 |
document.getElementById('error').style.display = "block";
|
|
|
119 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from pincode!';
|
|
|
120 |
window.scrollTo(0,0); return false;}
|
|
|
121 |
if(zipcode != zipcode.replace(/\s+/g, ' '))
|
|
|
122 |
{
|
|
|
123 |
document.getElementById('error').style.display = "block";
|
|
|
124 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from pincode!';
|
|
|
125 |
window.scrollTo(0,0); return false;}
|
|
|
126 |
if(phone =='')
|
|
|
127 |
{
|
|
|
128 |
document.getElementById('error').style.display = "block";
|
|
|
129 |
document.getElementById('error').innerHTML ='Please fill phone number field!';
|
|
|
130 |
window.scrollTo(0,0); return false;}
|
|
|
131 |
if(!/^\d+$/.test(phone))
|
|
|
132 |
{ document.getElementById('error').style.display = "block";
|
|
|
133 |
document.getElementById('error').innerHTML ='Please Use numbers only for Mobile Number!';
|
|
|
134 |
window.scrollTo(0,0); return false;}
|
|
|
135 |
if(phone.length != 10)
|
|
|
136 |
{ document.getElementById('error').style.display = "block";
|
|
|
137 |
document.getElementById('error').innerHTML ='Mobile number should be of 10 digits!';
|
|
|
138 |
window.scrollTo(0,0); return false;}
|
|
|
139 |
if(phone != phone.trim())
|
|
|
140 |
{
|
|
|
141 |
document.getElementById('error').style.display = "block";
|
|
|
142 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from phone number!';
|
|
|
143 |
window.scrollTo(0,0); return false;}
|
|
|
144 |
if(phone != phone.replace(/\s+/g, ' '))
|
|
|
145 |
{
|
|
|
146 |
document.getElementById('error').style.display = "block";
|
|
|
147 |
document.getElementById('error').innerHTML ='Please remove excess whitespaces from phone number!';
|
|
|
148 |
window.scrollTo(0,0); return false;}
|
|
|
149 |
|
|
|
150 |
}
|
|
|
151 |
function showForm(){
|
|
|
152 |
document.getElementsByClassName("address-form")[0].style.display = 'block';
|
|
|
153 |
document.getElementsByClassName("delivery-cont")[0].style.display = 'none';
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
function deleteAddress(e){
|
|
|
157 |
|
|
|
158 |
var addressId = e.currentTarget.id;
|
|
|
159 |
var url = base_url+'checkout/delete/'+addressId;
|
|
|
160 |
microAjax(url, function (res) {
|
|
|
161 |
|
|
|
162 |
if(res != ''){
|
|
|
163 |
document.getElementById(addressId).style.display = 'none';
|
|
|
164 |
}
|
|
|
165 |
});
|
|
|
166 |
e.stopPropagation();
|
|
|
167 |
}
|
|
|
168 |
function changeAddress(addressId,type){
|
|
|
169 |
|
|
|
170 |
if(defaultAddress != addressId){
|
|
|
171 |
var url = base_url+'checkout/changeAddress/'+addressId+'/'+type;
|
|
|
172 |
microAjax(url, function (res) {
|
|
|
173 |
|
|
|
174 |
if(res != ''){
|
|
|
175 |
var data = JSON.parse(res);
|
|
|
176 |
if(data.locationServiceable == false){
|
|
|
177 |
document.getElementById('error').style.display = "block";
|
|
|
178 |
document.getElementById('error').innerHTML = data.locationServiceableMessage;
|
|
|
179 |
locationServiceable = data.locationServiceable;
|
|
|
180 |
document.getElementById(defaultAddress).className = 'deliver-address';
|
|
|
181 |
document.getElementById(addressId).className += ' selected-add';
|
|
|
182 |
defaultAddress = addressId;
|
|
|
183 |
}else{
|
|
|
184 |
if(document.getElementById('error').style.display == "block"){
|
|
|
185 |
document.getElementById('error').style.display = "none";
|
|
|
186 |
}
|
|
|
187 |
document.getElementById(defaultAddress).className = 'deliver-address';
|
|
|
188 |
document.getElementById(addressId).className += ' selected-add';
|
|
|
189 |
defaultAddress = addressId;
|
|
|
190 |
locationServiceable = true;
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
else{
|
|
|
194 |
return false;
|
|
|
195 |
}
|
|
|
196 |
});
|
|
|
197 |
}
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
function changePayment(e){
|
|
|
201 |
|
|
|
202 |
var Id = e.currentTarget.id;
|
|
|
203 |
var defaultId = defaultPayment.id;
|
|
|
204 |
if(defaultId != Id){
|
|
|
205 |
var title = e.currentTarget.textContent.split('+')[0];
|
|
|
206 |
document.getElementById(defaultId).className = 'card';
|
|
|
207 |
defaultPayment.nextElementSibling.style.display = 'none';
|
|
|
208 |
defaultPayment.children[0].innerHTML = '+';
|
|
|
209 |
document.getElementById(Id).className += ' selected';
|
|
|
210 |
document.getElementById(Id).children[0].innerHTML = '-';
|
|
|
211 |
e.currentTarget.nextElementSibling.style.display = 'block';
|
|
|
212 |
//document.getElementById(Id).style.display = 'block';
|
|
|
213 |
defaultPayment = e.currentTarget;
|
|
|
214 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
215 |
_gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab clicked',title]);
|
|
|
216 |
}*/
|
|
|
217 |
ga('send', 'event', 'Payment Option', 'Payment option tab clicked', title);
|
|
|
218 |
}
|
|
|
219 |
}
|
|
|
220 |
if(typeof bankInfo != 'undefined'){
|
|
|
221 |
var defaultBank = bankInfo.Id;
|
|
|
222 |
}
|
|
|
223 |
function changeBank(e){
|
|
|
224 |
|
|
|
225 |
var Id = e.currentTarget.value;
|
|
|
226 |
var payOption = document.getElementById(Id).children[0].id;
|
|
|
227 |
document.getElementById(defaultBank).style.display = 'none';
|
|
|
228 |
document.getElementById(Id).style.display = 'block';
|
|
|
229 |
document.getElementById('pay-emi').value = payOption;
|
|
|
230 |
defaultBank = Id;
|
|
|
231 |
var id = e.currentTarget.id;
|
|
|
232 |
var a = document.getElementById(id);
|
|
|
233 |
var bankName = a.options[a.selectedIndex].text;
|
|
|
234 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
235 |
_gaq.push(['_trackEvent', 'EMI', 'Bank Selection',bankName]);
|
|
|
236 |
}*/
|
|
|
237 |
ga('send', 'event', 'EMI', 'Bank Selection', bankName);
|
|
|
238 |
}
|
|
|
239 |
function changePay(e){
|
|
|
240 |
|
|
|
241 |
var Id = e.currentTarget.id;
|
|
|
242 |
var payOption = document.getElementById('pay-emi').value;
|
|
|
243 |
document.getElementById(payOption).className = 'emi-body clearfix';
|
|
|
244 |
document.getElementById(Id).className += ' selected';
|
|
|
245 |
document.getElementById('pay-emi').value = Id;
|
|
|
246 |
var bankName = e.currentTarget.getAttribute('data-bank');
|
|
|
247 |
var tenure = e.currentTarget.getAttribute('data-tenure');
|
|
|
248 |
bankName = bankName+'-'+tenure;
|
|
|
249 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
250 |
_gaq.push(['_trackEvent', 'EMI', 'Plan Selection',bankName]);
|
|
|
251 |
}*/
|
|
|
252 |
ga('send', 'event', 'EMI', 'Plan Selection', bankName);
|
|
|
253 |
}
|
|
|
254 |
var netBankingInfo;
|
|
|
255 |
var prevClass;
|
|
|
256 |
function changeNetBanking(e){
|
|
|
257 |
|
|
|
258 |
var Id;
|
|
|
259 |
var selected;
|
|
|
260 |
var hasClass;
|
|
|
261 |
Id = e.currentTarget.value;
|
|
|
262 |
if(Id == undefined){
|
|
|
263 |
selected = 1;
|
|
|
264 |
Id = e.currentTarget.id;
|
|
|
265 |
var dropDown = document.getElementById('net');
|
|
|
266 |
if(dropDown.selectedIndex != 0){
|
|
|
267 |
dropDown.selectedIndex = 0;
|
|
|
268 |
}
|
|
|
269 |
}
|
|
|
270 |
if(netBankingInfo == undefined){
|
|
|
271 |
if((selected == 1))
|
|
|
272 |
document.getElementById(Id).className = 'selected';
|
|
|
273 |
}
|
|
|
274 |
else if(netBankingInfo != undefined){
|
|
|
275 |
if((selected == 1)) {
|
|
|
276 |
document.getElementById(Id).className = 'selected';
|
|
|
277 |
if(prevClass == 'selected'){
|
|
|
278 |
document.getElementById(netBankingInfo).className = '';
|
|
|
279 |
}
|
|
|
280 |
}else{
|
|
|
281 |
if(prevClass == 'selected'){
|
|
|
282 |
document.getElementById(netBankingInfo).className = '';
|
|
|
283 |
}
|
|
|
284 |
}
|
|
|
285 |
}
|
|
|
286 |
document.getElementById('pay-net').value = Id;
|
|
|
287 |
netBankingInfo = Id;
|
|
|
288 |
prevClass = e.currentTarget.className;
|
|
|
289 |
var title = e.currentTarget.getAttribute('data-parent');
|
|
|
290 |
title = title+'-'+Id;
|
|
|
291 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
292 |
_gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
|
|
|
293 |
}*/
|
|
|
294 |
ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
|
|
|
295 |
}
|
|
|
296 |
var countryId;
|
|
|
297 |
function changeCountry(e){
|
|
|
298 |
|
|
|
299 |
var Id = e.currentTarget.id;
|
|
|
300 |
countryId = Id;
|
|
|
301 |
if(Id == 'india'){
|
|
|
302 |
document.getElementById('india').className = 'selected';
|
|
|
303 |
document.getElementById('outside').className = '';
|
|
|
304 |
document.getElementsByClassName('in-india')[0].style.display = 'block';
|
|
|
305 |
document.getElementsByClassName('out-india')[0].style.display = 'none';
|
|
|
306 |
}
|
|
|
307 |
if(Id == 'outside'){
|
|
|
308 |
document.getElementById('outside').className = 'selected';
|
|
|
309 |
document.getElementById('india').className = '';
|
|
|
310 |
document.getElementsByClassName('out-india')[0].style.display = 'block';
|
|
|
311 |
document.getElementsByClassName('in-india')[0].style.display = 'none';
|
|
|
312 |
}
|
|
|
313 |
}
|
|
|
314 |
var previousCard;
|
|
|
315 |
function selectCard(e){
|
|
|
316 |
|
|
|
317 |
var Id = e.currentTarget.id;
|
|
|
318 |
if(previousCard == undefined){
|
|
|
319 |
e.currentTarget.className = 'selected';
|
|
|
320 |
}
|
|
|
321 |
else if(previousCard != undefined){
|
|
|
322 |
previousCard.className = '';
|
|
|
323 |
e.currentTarget.className = 'selected';
|
|
|
324 |
}
|
|
|
325 |
document.getElementById('pay-credit').value = Id;
|
|
|
326 |
previousCard = e.currentTarget;
|
|
|
327 |
var title = e.currentTarget.getAttribute('data-parent');
|
|
|
328 |
title = title+'-'+Id;
|
|
|
329 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
330 |
_gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
|
|
|
331 |
}*/
|
|
|
332 |
ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
|
|
|
333 |
}
|
|
|
334 |
var previousDebit;
|
|
|
335 |
function selectDebitCard(e){
|
|
|
336 |
|
|
|
337 |
var Id = e.currentTarget.id;
|
|
|
338 |
if(previousDebit == undefined){
|
|
|
339 |
e.currentTarget.className = 'selected';
|
|
|
340 |
}
|
|
|
341 |
else if(previousDebit != undefined){
|
|
|
342 |
previousDebit.className = '';
|
|
|
343 |
e.currentTarget.className = 'selected';
|
|
|
344 |
}
|
|
|
345 |
document.getElementById('pay-debit').value = Id;
|
|
|
346 |
previousDebit = e.currentTarget;
|
|
|
347 |
var title = e.currentTarget.getAttribute('data-parent');
|
|
|
348 |
title = title+'-'+Id;
|
|
|
349 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
350 |
_gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
|
|
|
351 |
}*/
|
|
|
352 |
ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
|
|
|
353 |
}
|
|
|
354 |
var previousCC;
|
|
|
355 |
function selectCashCard(e){
|
|
|
356 |
|
|
|
357 |
var Id = e.currentTarget.id;
|
|
|
358 |
if(previousCC == undefined){
|
|
|
359 |
e.currentTarget.className = 'selected';
|
|
|
360 |
}
|
|
|
361 |
else if(previousCC != undefined){
|
|
|
362 |
previousCC.className = '';
|
|
|
363 |
e.currentTarget.className = 'selected';
|
|
|
364 |
}
|
|
|
365 |
document.getElementById('pay-cc').value = Id;
|
|
|
366 |
previousCC = e.currentTarget;
|
|
|
367 |
var title = e.currentTarget.getAttribute('data-parent');
|
|
|
368 |
title = title+'-'+Id;
|
|
|
369 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
370 |
_gaq.push(['_trackEvent', 'Payment Option', 'Payment option tab-payoption selected',title]);
|
|
|
371 |
}*/
|
|
|
372 |
ga('send', 'event', 'Payment Option', 'Payment option tab-payoption selected', title);
|
|
|
373 |
}
|
|
|
374 |
// function changeCaptcha(){
|
|
|
375 |
// var url = base_url+'checkout/changeCaptcha';
|
|
|
376 |
// microAjax(url, function (res) {
|
|
|
377 |
//
|
|
|
378 |
// if(res != ''){
|
|
|
379 |
//
|
|
|
380 |
// data = JSON.parse(res);
|
|
|
381 |
// document.getElementById('captcha').innerHTML = data.image;
|
|
|
382 |
// }
|
|
|
383 |
// else{
|
|
|
384 |
// return false;
|
|
|
385 |
// }
|
|
|
386 |
// });
|
|
|
387 |
// }
|
|
|
388 |
function infoPage(){
|
|
|
389 |
document.getElementsByClassName("address-form")[0].style.display = 'none';
|
|
|
390 |
document.getElementsByClassName("delivery-cont")[0].style.display = 'block';
|
|
|
391 |
}
|
|
|
392 |
var prevDiv;
|
|
|
393 |
var pickupStore;
|
|
|
394 |
function togglepicup(e){
|
|
|
395 |
|
|
|
396 |
if(document.getElementById('error').style.display == 'block'){
|
|
|
397 |
document.getElementById('error').style.display = 'none';
|
|
|
398 |
}
|
|
|
399 |
prevDiv = e.currentTarget.className;
|
|
|
400 |
if(e.currentTarget.className == 'pick-up'){
|
|
|
401 |
pickupStore = true;
|
|
|
402 |
inStoreDelivery = false;
|
|
|
403 |
e.currentTarget.className += ' selected';
|
|
|
404 |
document.getElementsByClassName("deliverhere")[0].setAttribute('class','deliverhere');
|
|
|
405 |
document.getElementsByClassName("pickup")[0].style.display = 'block';
|
|
|
406 |
document.getElementsByClassName("deliver-here")[0].style.display = 'none';
|
|
|
407 |
}else if(prevDiv.indexOf('pick-up') == -1){
|
|
|
408 |
e.currentTarget.className += ' selected';
|
|
|
409 |
pickupStore = false;
|
|
|
410 |
document.getElementsByClassName("pick-up")[0].setAttribute('class','pick-up');
|
|
|
411 |
document.getElementsByClassName("deliver-here")[0].style.display = 'block';
|
|
|
412 |
document.getElementsByClassName("pickup")[0].style.display = 'none';
|
|
|
413 |
|
|
|
414 |
}
|
|
|
415 |
}
|
|
|
416 |
var prevZone;
|
|
|
417 |
function changeZone(e){
|
|
|
418 |
|
|
|
419 |
var value = e.currentTarget.value;
|
|
|
420 |
var currentStore = storeInfo[value];
|
|
|
421 |
var storeAddress = '';
|
|
|
422 |
if(prevZone == undefined || prevZone != value){
|
|
|
423 |
for(i=0;i<currentStore.length;i++){
|
|
|
424 |
storeAddress +='<div class="pickup-spot" id="'+currentStore[i].id+'" data-key="'+currentStore[i].hotspotId+'" onclick=selectStore(event)><div>'+currentStore[i].name+'</div><div>'+currentStore[i].line1+'</div><div>'+currentStore[i].line2+'</div><div>'+currentStore[i].city+'</div><div>'+currentStore[i].state+'</div><div>Pin: '+currentStore[i].pin+'</div><div>Phone: '+currentStore[i].phone+'</div></div>';
|
|
|
425 |
}
|
|
|
426 |
document.getElementById('appendData').innerHTML = storeAddress;
|
|
|
427 |
prevZone = value;
|
|
|
428 |
/* if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
429 |
_gaq.push(['_trackEvent', 'InStore Pickup Region', 'Store Zone',value]);
|
|
|
430 |
}*/
|
|
|
431 |
ga('send', 'event', 'InStore Pickup Region', 'Store Zone', value);
|
|
|
432 |
}
|
|
|
433 |
}
|
|
|
434 |
var shopId;
|
|
|
435 |
var inStoreDelivery;
|
|
|
436 |
function selectStore(e){
|
|
|
437 |
|
|
|
438 |
var id = e.currentTarget.id;
|
|
|
439 |
var hotspotId = e.currentTarget;
|
|
|
440 |
if(shopId == undefined){
|
|
|
441 |
document.getElementById(id).className += ' selected-add';
|
|
|
442 |
shopId = id;
|
|
|
443 |
inStoreDelivery = true;
|
|
|
444 |
}else if(shopId != id){
|
|
|
445 |
if(document.getElementById(shopId)){
|
|
|
446 |
document.getElementById(shopId).className += 'pickup-spot';
|
|
|
447 |
}
|
|
|
448 |
document.getElementById(id).className += ' selected-add';
|
|
|
449 |
shopId = id;
|
|
|
450 |
inStoreDelivery = true;
|
|
|
451 |
}
|
|
|
452 |
var url = base_url+'checkout/pickupSpot/'+id;
|
|
|
453 |
microAjax(url,function(res){
|
|
|
454 |
|
|
|
455 |
if(res != ''){
|
|
|
456 |
}else{
|
|
|
457 |
window.location.href = document.URL;
|
|
|
458 |
}
|
|
|
459 |
});
|
|
|
460 |
document.getElementById('hotSpot').value = id;
|
|
|
461 |
}
|
|
|
462 |
if(insuranceInfo != undefined){
|
|
|
463 |
var insuranceInfo = insuranceInfo;
|
|
|
464 |
}
|
|
|
465 |
function validateInsurance(type){
|
|
|
466 |
|
|
|
467 |
var type = type;
|
|
|
468 |
if(document.getElementById('ccAddress') && insuranceInfo == 1){
|
|
|
469 |
var bday = document.getElementById('bday').value;
|
|
|
470 |
var gname = document.getElementById('gName').value;
|
|
|
471 |
if(gname == '')
|
|
|
472 |
{
|
|
|
473 |
document.getElementById('error1').style.display = "block";
|
|
|
474 |
document.getElementById('error1').innerHTML ='Please fill name field!';
|
|
|
475 |
return false;}
|
|
|
476 |
if(gname.length> 50)
|
|
|
477 |
{
|
|
|
478 |
document.getElementById('error1').style.display = "block";
|
|
|
479 |
document.getElementById('error1').innerHTML ='Please Enter Less Than 50 Characters in name field!';
|
|
|
480 |
return false;}
|
|
|
481 |
if(gname != gname.trim())
|
|
|
482 |
{
|
|
|
483 |
document.getElementById('error1').style.display = "block";
|
|
|
484 |
document.getElementById('error1').innerHTML ='Please remove excess whitespace from name field!';
|
|
|
485 |
return false;}
|
|
|
486 |
if(gname != gname.replace(/\s+/g,' '))
|
|
|
487 |
{
|
|
|
488 |
document.getElementById('error1').style.display = "block";
|
|
|
489 |
document.getElementById('error1').innerHTML ='Please remove excess whitespace from name field!';
|
|
|
490 |
return false;}
|
|
|
491 |
var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
|
|
|
492 |
var returnval=false
|
|
|
493 |
if (!validformat.test(bday)){
|
|
|
494 |
document.getElementById('error1').style.display = "block";
|
|
|
495 |
document.getElementById('error1').innerHTML ='Please Enter valid date';
|
|
|
496 |
return false;
|
|
|
497 |
}else if(validformat.test(bday)){ //Detailed check for valid date ranges
|
|
|
498 |
var monthfield=bday.split("/")[0]
|
|
|
499 |
var dayfield=bday.split("/")[1]
|
|
|
500 |
var yearfield=bday.split("/")[2]
|
|
|
501 |
var dayobj = new Date(yearfield, monthfield-1, dayfield);
|
|
|
502 |
var today = new Date();
|
|
|
503 |
var limit = new Date('1900/01/01');
|
|
|
504 |
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)){
|
|
|
505 |
document.getElementById('error1').style.display = "block";
|
|
|
506 |
document.getElementById('error1').innerHTML ='Invalid Day, Month, or Year range detected. Please correct and submit again.';
|
|
|
507 |
return false;
|
|
|
508 |
}
|
|
|
509 |
if (dayobj > today){
|
|
|
510 |
document.getElementById('error1').style.display = "block";
|
|
|
511 |
document.getElementById('error1').innerHTML ="Date should be less than today's date" ;
|
|
|
512 |
return false;
|
|
|
513 |
}
|
|
|
514 |
if (dayobj < limit){
|
|
|
515 |
document.getElementById('error1').style.display = "block";
|
|
|
516 |
document.getElementById('error1').innerHTML ="Date should be greater than 1st jan 1940" ;
|
|
|
517 |
return false;
|
|
|
518 |
}
|
|
|
519 |
}
|
|
|
520 |
var alreadySubmitted;
|
|
|
521 |
if((type == 1 || type == 2) && alreadySubmitted != true){
|
|
|
522 |
alreadySubmitted = true;
|
|
|
523 |
var bday = bday.replace(/\//g, '-');
|
|
|
524 |
gname = gname.replace(/\ /g,'-');
|
|
|
525 |
var url = base_url+'checkout/insuranceInfo/'+bday+'/'+gname+'/'+insuranceAddressId;
|
|
|
526 |
microAjax(url,function(res){
|
|
|
527 |
|
|
|
528 |
if(res != ''){
|
|
|
529 |
|
|
|
530 |
var data = JSON.parse(res);
|
|
|
531 |
if(data['response'].status == 'SUCCESS'){
|
|
|
532 |
if(document.getElementById('ccAddress').style.display == ''){
|
|
|
533 |
document.getElementById('ccAddress').style.display = 'none';
|
|
|
534 |
}
|
|
|
535 |
}
|
|
|
536 |
else{
|
|
|
537 |
alreadySubmitted = false;
|
|
|
538 |
document.getElementById('error1').style.display = "block";
|
|
|
539 |
document.getElementById('error1').innerHTML ='Request could not be completed.Please try again!';
|
|
|
540 |
return false;
|
|
|
541 |
}
|
|
|
542 |
}
|
|
|
543 |
});
|
|
|
544 |
}
|
|
|
545 |
if(type == 2){
|
|
|
546 |
if(pickupStore == true){
|
|
|
547 |
if(inStoreDelivery == true){
|
|
|
548 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
549 |
_gaq.push(['_trackEvent', 'Delivery Type','In-Store Pickup']);
|
|
|
550 |
}*/
|
|
|
551 |
ga('send', 'event', 'Delivery Type', 'In-Store Pickup');
|
|
|
552 |
}else if(inStoreDelivery == false){
|
|
|
553 |
document.getElementById('error').style.display = "block";
|
|
|
554 |
document.getElementById('error').innerHTML ="Please select a delivery store!" ;
|
|
|
555 |
return false;
|
|
|
556 |
}
|
|
|
557 |
}else{
|
|
|
558 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
559 |
_gaq.push(['_trackEvent', 'Delivery Type','Deliver to address']);
|
|
|
560 |
}*/
|
|
|
561 |
ga('send', 'event', 'Delivery Type', 'Deliver to address');
|
|
|
562 |
}
|
|
|
563 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
564 |
_gaq.push(['_trackEvent', 'Order','Proceed To Pay']);
|
|
|
565 |
}*/
|
|
|
566 |
ga('send', 'event', 'Order', 'Proceed To Pay');
|
|
|
567 |
if(locationServiceable == false){
|
|
|
568 |
document.getElementById('error').style.display = "block";
|
|
|
569 |
document.getElementById('error').innerHTML ='Location not serviceable. Please specify a different address';
|
|
|
570 |
return false;
|
|
|
571 |
}
|
|
|
572 |
window.location.href = base_url+'payment';
|
|
|
573 |
}
|
|
|
574 |
}else{
|
|
|
575 |
if(pickupStore == true){
|
|
|
576 |
if(inStoreDelivery == true){
|
|
|
577 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
578 |
_gaq.push(['_trackEvent', 'Delivery Type','In-Store Pickup']);
|
|
|
579 |
}*/
|
|
|
580 |
ga('send', 'event', 'Delivery Type', 'In-Store Pickup');
|
|
|
581 |
}else if(inStoreDelivery == false){
|
|
|
582 |
document.getElementById('error').style.display = "block";
|
|
|
583 |
document.getElementById('error').innerHTML ="Please select a delivery store!" ;
|
|
|
584 |
return false;
|
|
|
585 |
}
|
|
|
586 |
}else{
|
|
|
587 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
588 |
_gaq.push(['_trackEvent', 'Delivery Type','Deliver to address']);
|
|
|
589 |
}*/
|
|
|
590 |
ga('send', 'event', 'Delivery Type', 'Deliver to address');
|
|
|
591 |
}
|
|
|
592 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
593 |
_gaq.push(['_trackEvent', 'Order','Proceed To Pay']);
|
|
|
594 |
}*/
|
|
|
595 |
ga('send', 'event', 'Order', 'Proceed To Pay');
|
|
|
596 |
if(locationServiceable == false){
|
|
|
597 |
document.getElementById('error').style.display = "block";
|
|
|
598 |
document.getElementById('error').innerHTML ='Location not serviceable. Please specify a different address';
|
|
|
599 |
return false;
|
|
|
600 |
}
|
|
|
601 |
window.location.href = base_url+'payment';
|
|
|
602 |
}
|
|
|
603 |
}
|
|
|
604 |
function paymentValidation(e){
|
|
|
605 |
|
|
|
606 |
var Id = e.currentTarget.id;
|
|
|
607 |
if(Id == 'creditcard'){
|
|
|
608 |
if(previousCard == undefined){
|
|
|
609 |
document.getElementById('error').style.display = "block";
|
|
|
610 |
document.getElementById('error').innerHTML ='Please select payment method!';
|
|
|
611 |
window.scrollTo(0,0); return false;
|
|
|
612 |
}
|
|
|
613 |
var paymentTitle = e.currentTarget.getAttribute('data-key');
|
|
|
614 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
615 |
_gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
|
|
|
616 |
}*/
|
|
|
617 |
ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
|
|
|
618 |
|
|
|
619 |
}else if(Id == 'debitcard'){
|
|
|
620 |
if(previousDebit == undefined){
|
|
|
621 |
document.getElementById('error').style.display = "block";
|
|
|
622 |
document.getElementById('error').innerHTML ='Please select payment method!';
|
|
|
623 |
window.scrollTo(0,0); return false;
|
|
|
624 |
}
|
|
|
625 |
var paymentTitle = e.currentTarget.getAttribute('data-key');
|
|
|
626 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
627 |
_gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
|
|
|
628 |
}*/
|
|
|
629 |
ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
|
|
|
630 |
}else if(Id == 'netbanking'){
|
|
|
631 |
var payOption = document.getElementById('pay-net').value;
|
|
|
632 |
if(payOption == undefined || payOption ==""){
|
|
|
633 |
document.getElementById('error').style.display = "block";
|
|
|
634 |
document.getElementById('error').innerHTML ='Please select payment method!';
|
|
|
635 |
window.scrollTo(0,0); return false;
|
|
|
636 |
}
|
|
|
637 |
var paymentTitle = e.currentTarget.getAttribute('data-key');
|
|
|
638 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
639 |
_gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
|
|
|
640 |
}*/
|
|
|
641 |
ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
|
|
|
642 |
}else if(Id == 'cashcards'){
|
|
|
643 |
if(previousCC == undefined){
|
|
|
644 |
document.getElementById('error').style.display = "block";
|
|
|
645 |
document.getElementById('error').innerHTML ='Please select payment method!';
|
|
|
646 |
window.scrollTo(0,0); return false;
|
|
|
647 |
}
|
|
|
648 |
var paymentTitle = e.currentTarget.getAttribute('data-key');
|
|
|
649 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
650 |
_gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
|
|
|
651 |
}*/
|
|
|
652 |
ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
|
|
|
653 |
}else if(Id == 'emiform'){
|
|
|
654 |
var payOption = document.getElementById('pay-emi').value;
|
|
|
655 |
if(payOption == undefined || payOption ==""){
|
|
|
656 |
document.getElementById('error').style.display = "block";
|
|
|
657 |
document.getElementById('error').innerHTML ='Please select payment method!';
|
|
|
658 |
window.scrollTo(0,0); return false;
|
|
|
659 |
}
|
|
|
660 |
var paymentTitle = e.currentTarget.getAttribute('data-key');
|
|
|
661 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
662 |
_gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
|
|
|
663 |
}*/
|
|
|
664 |
ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
|
|
|
665 |
}else if(Id == 'cashod'){
|
|
|
666 |
if(document.getElementById('captcha_response_box').value == ''){
|
|
|
667 |
// document.forms['recharge-confirm'].submit();
|
|
|
668 |
// }else{
|
|
|
669 |
var bRed = document.getElementById('captcha_response_box');
|
|
|
670 |
bRed.style.border = 'red solid 1px';
|
|
|
671 |
bRed.style.color = 'red';
|
|
|
672 |
bRed.value = 'Please enter the captcha'
|
|
|
673 |
setTimeout(function(){
|
|
|
674 |
bRed.style.border = '';
|
|
|
675 |
bRed.style.color = '';
|
|
|
676 |
bRed.value = '';
|
|
|
677 |
},3000);
|
|
|
678 |
return false;
|
|
|
679 |
}
|
|
|
680 |
var paymentTitle = e.currentTarget.getAttribute('data-key');
|
|
|
681 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
682 |
_gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
|
|
|
683 |
}*/
|
|
|
684 |
ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
|
|
|
685 |
}else if(Id == 'zod'){
|
|
|
686 |
if(document.getElementById('captcha_response_box').value == ''){
|
|
|
687 |
// document.forms['recharge-confirm'].submit();
|
|
|
688 |
// }else{
|
|
|
689 |
var bRed = document.getElementById('captcha_response_box');
|
|
|
690 |
bRed.style.border = 'red solid 1px';
|
|
|
691 |
bRed.style.color = 'red';
|
|
|
692 |
bRed.value = 'Please enter the captcha'
|
|
|
693 |
setTimeout(function(){
|
|
|
694 |
bRed.style.border = '';
|
|
|
695 |
bRed.style.color = '';
|
|
|
696 |
bRed.value = '';
|
|
|
697 |
},3000);
|
|
|
698 |
return false;
|
|
|
699 |
}
|
|
|
700 |
var paymentTitle = e.currentTarget.getAttribute('data-key');
|
|
|
701 |
/*if(typeof _gaq != "undefined" && _gaq != null) {
|
|
|
702 |
_gaq.push(['_trackEvent', 'Payment Option', 'Form Submission',paymentTitle]);
|
|
|
703 |
}*/
|
|
|
704 |
ga('send', 'event', 'Payment Option', 'Form Submission',paymentTitle);
|
|
|
705 |
}
|
|
|
706 |
}
|
|
|
707 |
var url;
|
|
|
708 |
url = document.URL;
|
|
|
709 |
if(url.indexOf('pay-success') != -1){
|
|
|
710 |
if(orderConfirmation != undefined){
|
|
|
711 |
if(!storeName){
|
|
|
712 |
storeName = 'Saholic';
|
|
|
713 |
}
|
|
|
714 |
var orders = orderConfirmation['result']['orders'];
|
|
|
715 |
for(i=0;i<orders.length;i++){
|
|
|
716 |
var amount = orders[i].totalAmount.replace(',','');
|
|
|
717 |
amount = parseFloat(amount).toFixed(2);
|
|
|
718 |
var orderId = orders[i].orderId;
|
|
|
719 |
/*
|
|
|
720 |
_gaq.push(['_addTrans',
|
|
|
721 |
orderId, // Transaction ID. Required.
|
|
|
722 |
storeName, // Affiliation or store name.
|
|
|
723 |
amount, // Grand Total.
|
|
|
724 |
'0', // Shipping.
|
|
|
725 |
'0', // Tax.
|
|
|
726 |
"",
|
|
|
727 |
"",
|
|
|
728 |
"India"
|
|
|
729 |
]);
|
|
|
730 |
_gaq.push(['_addItem',
|
|
|
731 |
orderId, // Transaction ID. Required.
|
|
|
732 |
orders[i].itemName, // Product name. Required.
|
|
|
733 |
orders[i].itemName, // SKU/code.
|
|
|
734 |
'Physical', // Category or variation.
|
|
|
735 |
amount, // Unit price.
|
|
|
736 |
orders[i].quantity // Quantity.
|
|
|
737 |
]);
|
|
|
738 |
*/
|
|
|
739 |
ga('ecommerce:addTransaction', {
|
|
|
740 |
'id': orderId, // Transaction ID. Required
|
|
|
741 |
'affiliation': storeName, // Affiliation or store name
|
|
|
742 |
'revenue': amount, // Grand Total
|
|
|
743 |
'shipping': '0', // Shipping
|
|
|
744 |
'tax': '0' // Tax
|
|
|
745 |
});
|
|
|
746 |
// addItem should be called for every item in the shopping cart.
|
|
|
747 |
ga('ecommerce:addItem', {
|
|
|
748 |
'id': orderId, // Transaction ID. Required
|
|
|
749 |
'name': orders[i].itemName, // Product name. Required
|
|
|
750 |
'sku': orders[i].itemName, // SKU/code
|
|
|
751 |
'category': 'Physical', // Category or variation
|
|
|
752 |
'price': amount, // Unit price
|
|
|
753 |
'quantity': orders[i].quantity // Quantity
|
|
|
754 |
});
|
|
|
755 |
}
|
|
|
756 |
// _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
|
|
|
757 |
ga('ecommerce:send'); // Send transaction and item data to Google Analytics.
|
|
|
758 |
}
|
|
|
759 |
}
|