| 17804 |
manish.sha |
1 |
function loadCartDetails(){
|
| 17766 |
manish.sha |
2 |
$('.itemquantity').attr('disabled', 'true');
|
|
|
3 |
var cart_details = localStorage.getItem('cart_details');
|
|
|
4 |
if(cart_details==undefined){
|
|
|
5 |
$(".pmfooter span.carttotalval").text('0');
|
| 17871 |
manish.sha |
6 |
$(".pmfooter span.carttotalitemsval").text('0');
|
| 17766 |
manish.sha |
7 |
$(".pmfooter span.badge").text('0');
|
|
|
8 |
$(".pmfooter").addClass('hidden');
|
|
|
9 |
}else{
|
|
|
10 |
var cartDetailsObj = JSON.parse(cart_details);
|
|
|
11 |
if(cartDetailsObj.totalCartQuantity > 0){
|
|
|
12 |
$(".pmfooter span.badge").text(cartDetailsObj.totalCartQuantity.toString());
|
| 17871 |
manish.sha |
13 |
$(".pmfooter span.carttotalitemsval").text(cartDetailsObj.totalSkus.toString());
|
| 17766 |
manish.sha |
14 |
var totalCartValue = cartDetailsObj.totalCartValue;
|
|
|
15 |
var priceChangeMap = {};
|
|
|
16 |
$.each(cartDetailsObj.cartItems, function(key,val) {
|
|
|
17 |
var newUnitPrice = $(".number-spinner button[data-id='"+key+"']").data('price');
|
| 17774 |
manish.sha |
18 |
if(newUnitPrice!=undefined){
|
|
|
19 |
$(".number-spinner button[data-id='"+key+"']").closest('.number-spinner').find('input').val(val.quantity);
|
|
|
20 |
if(parseInt(newUnitPrice)!=parseInt(val.unitprice)){
|
|
|
21 |
totalCartValue = totalCartValue - (parseInt(val.unitprice)*parseInt(val.quantity)) + (parseInt(newUnitPrice)*parseInt(val.quantity));
|
|
|
22 |
priceChangeMap[key] = newUnitPrice;
|
|
|
23 |
}
|
| 17766 |
manish.sha |
24 |
}
|
|
|
25 |
});
|
|
|
26 |
$(".pmfooter span.carttotalval").text(numberWithCommas(totalCartValue));
|
| 17774 |
manish.sha |
27 |
if(totalCartValue!=undefined){
|
|
|
28 |
cartDetailsObj.totalCartValue = totalCartValue;
|
|
|
29 |
}
|
| 17766 |
manish.sha |
30 |
var cartItems = cartDetailsObj.cartItems;
|
|
|
31 |
$.each(priceChangeMap, function(key,val) {
|
| 17804 |
manish.sha |
32 |
cartItems[key].unitprice = val;
|
| 17766 |
manish.sha |
33 |
});
|
|
|
34 |
cartDetailsObj.cartItems = cartItems;
|
|
|
35 |
localStorage.setItem('cart_details',JSON.stringify(cartDetailsObj));
|
|
|
36 |
$(".pmfooter").removeClass('hidden');
|
|
|
37 |
}else{
|
| 17827 |
manish.sha |
38 |
$.each(cartDetailsObj.cartItems, function(key,val) {
|
|
|
39 |
var newUnitPrice = $(".number-spinner button[data-id='"+key+"']").data('price');
|
|
|
40 |
if(newUnitPrice!=undefined){
|
|
|
41 |
$(".number-spinner button[data-id='"+key+"']").closest('.number-spinner').find('input').val(val.quantity);
|
|
|
42 |
if(parseInt(newUnitPrice)!=parseInt(val.unitprice)){
|
|
|
43 |
totalCartValue = totalCartValue - (parseInt(val.unitprice)*parseInt(val.quantity)) + (parseInt(newUnitPrice)*parseInt(val.quantity));
|
|
|
44 |
priceChangeMap[key] = newUnitPrice;
|
|
|
45 |
}
|
|
|
46 |
}
|
|
|
47 |
});
|
| 17766 |
manish.sha |
48 |
$(".pmfooter span.carttotalval").text('0');
|
|
|
49 |
$(".pmfooter span.badge").text('0');
|
| 17871 |
manish.sha |
50 |
$(".pmfooter span.carttotalitemsval").text('0');
|
| 17766 |
manish.sha |
51 |
$(".pmfooter").addClass('hidden');
|
|
|
52 |
}
|
| 17804 |
manish.sha |
53 |
}
|
| 17909 |
manish.sha |
54 |
if(!$('div.pmfooter').hasClass('hidden')) {
|
|
|
55 |
$('div.content').attr('style', 'margin-bottom: 42px');
|
|
|
56 |
}else{
|
|
|
57 |
$('div.content').attr('style', 'margin-bottom: 0px');
|
|
|
58 |
}
|
| 17766 |
manish.sha |
59 |
}
|
| 17804 |
manish.sha |
60 |
$(function(){
|
|
|
61 |
loadCartDetails();
|
|
|
62 |
});
|
|
|
63 |
$(document).on('click','.number-spinner button',function(){
|
| 17766 |
manish.sha |
64 |
btn = $(this);
|
|
|
65 |
input = btn.closest('.number-spinner').find('input');
|
|
|
66 |
oldValue = btn.closest('.number-spinner').find('input').val().trim(),
|
|
|
67 |
newVal = 0;
|
|
|
68 |
btn.closest('.number-spinner').find('button').prop("disabled", false);
|
|
|
69 |
var totalCartQuantity = 0;
|
|
|
70 |
var totalCartValue = 0;
|
| 17871 |
manish.sha |
71 |
var totalSkus = 0;
|
| 17766 |
manish.sha |
72 |
var cartDetailsObj;
|
|
|
73 |
var jsonObjToBeStored = {};
|
|
|
74 |
var cartItems = {};
|
|
|
75 |
var cart_details = localStorage.getItem('cart_details');
|
|
|
76 |
if(cart_details!=undefined){
|
|
|
77 |
cartDetailsObj = JSON.parse(cart_details);
|
|
|
78 |
totalCartQuantity = cartDetailsObj.totalCartQuantity;
|
|
|
79 |
totalCartValue = cartDetailsObj.totalCartValue;
|
|
|
80 |
cartItems = cartDetailsObj.cartItems;
|
|
|
81 |
}
|
|
|
82 |
var inc = 0;
|
|
|
83 |
var dec = 0;
|
|
|
84 |
var sku = btn.data('id');
|
|
|
85 |
var unitPrice = btn.data('price');
|
|
|
86 |
var prodname = $(".number-spinner").data('name');
|
|
|
87 |
var brandname = $(".number-spinner").data('brand');
|
|
|
88 |
if (btn.attr('data-dir') == 'up') {
|
|
|
89 |
if ( input.attr('max') == undefined || parseInt(input.val()) < parseInt(input.attr('max')) ) {
|
|
|
90 |
if(parseInt(input.val())<5){
|
|
|
91 |
inc = 1;
|
|
|
92 |
newVal = parseInt(oldValue) + inc;
|
|
|
93 |
}else{
|
|
|
94 |
inc = 5-(parseInt(input.val())%5);
|
|
|
95 |
newVal = parseInt(oldValue) + inc;
|
| 17804 |
manish.sha |
96 |
if(newVal>parseInt(input.attr('max'))){
|
|
|
97 |
inc = parseInt(input.attr('max')) - parseInt(oldValue);
|
|
|
98 |
newVal = parseInt(oldValue) + inc;
|
|
|
99 |
}
|
| 17766 |
manish.sha |
100 |
}
|
|
|
101 |
}else{
|
|
|
102 |
newVal = parseInt(oldValue);
|
|
|
103 |
btn.prop("disabled", true);
|
|
|
104 |
}
|
| 17909 |
manish.sha |
105 |
if(newVal==parseInt(input.attr('max'))){
|
|
|
106 |
input.attr('style', 'border: 2px solid #ff0000');
|
|
|
107 |
}else{
|
|
|
108 |
input.attr('style', 'border: 1px solid #CCCCCC');
|
|
|
109 |
}
|
| 17766 |
manish.sha |
110 |
totalCartQuantity = totalCartQuantity + inc;
|
|
|
111 |
} else {
|
|
|
112 |
if ( input.attr('min') == undefined || parseInt(input.val()) > parseInt(input.attr('min')) ) {
|
|
|
113 |
dec = 1;
|
|
|
114 |
newVal = parseInt(oldValue) - dec;
|
|
|
115 |
}else{
|
|
|
116 |
btn.prop("disabled", true);
|
|
|
117 |
}
|
| 17909 |
manish.sha |
118 |
if(newVal==parseInt(input.attr('min'))){
|
|
|
119 |
input.attr('style', 'border: 2px solid #5bc0de');
|
|
|
120 |
}else{
|
|
|
121 |
input.attr('style', 'border: 1px solid #CCCCCC');
|
|
|
122 |
}
|
| 17766 |
manish.sha |
123 |
totalCartQuantity = totalCartQuantity - dec;
|
|
|
124 |
}
|
|
|
125 |
|
|
|
126 |
btn.closest('.number-spinner').find('input').val(newVal);
|
|
|
127 |
if(cartDetailsObj==undefined){
|
|
|
128 |
jsonObjToBeStored['totalCartQuantity'] = totalCartQuantity;
|
|
|
129 |
totalCartValue = totalCartValue + (unitPrice * newVal);
|
|
|
130 |
jsonObjToBeStored['totalCartValue'] = totalCartValue;
|
|
|
131 |
var itemDetail = {};
|
|
|
132 |
itemDetail['quantity']=newVal;
|
|
|
133 |
itemDetail['unitprice']=unitPrice;
|
|
|
134 |
itemDetail['productname']=prodname;
|
|
|
135 |
itemDetail['brand']=brandname;
|
|
|
136 |
cartItems[sku.toString()]=itemDetail;
|
| 17871 |
manish.sha |
137 |
$.each( cartItems, function(itemId,value){
|
|
|
138 |
if(value['quantity']>0){
|
|
|
139 |
totalSkus = totalSkus +1;
|
|
|
140 |
}
|
|
|
141 |
});
|
| 17766 |
manish.sha |
142 |
jsonObjToBeStored['cartItems']=cartItems;
|
| 17871 |
manish.sha |
143 |
jsonObjToBeStored['totalSkus']=totalSkus;
|
| 17766 |
manish.sha |
144 |
localStorage.setItem('cart_details',JSON.stringify(jsonObjToBeStored));
|
|
|
145 |
}else{
|
|
|
146 |
cartDetailsObj.totalCartQuantity = totalCartQuantity;
|
|
|
147 |
var itemDetail = cartItems[sku.toString()];
|
|
|
148 |
if(itemDetail==undefined){
|
|
|
149 |
var itemDetail = {};
|
|
|
150 |
itemDetail['quantity']=newVal;
|
|
|
151 |
itemDetail['unitprice']=unitPrice;
|
|
|
152 |
itemDetail['productname']=prodname;
|
|
|
153 |
itemDetail['brand']=brandname;
|
|
|
154 |
totalCartValue = totalCartValue + (unitPrice * newVal);
|
|
|
155 |
cartItems[sku.toString()]=itemDetail;
|
|
|
156 |
}else{
|
|
|
157 |
totalCartValue = totalCartValue - (cartItems[sku.toString()].quantity * cartItems[sku.toString()].unitprice) + (unitPrice * newVal);
|
|
|
158 |
if(newVal==0){
|
| 17831 |
manish.sha |
159 |
cartItems[sku.toString()].quantity = 0;
|
|
|
160 |
cartItems[sku.toString()].unitprice = unitPrice;
|
| 17766 |
manish.sha |
161 |
}else{
|
|
|
162 |
cartItems[sku.toString()].quantity = newVal;
|
|
|
163 |
cartItems[sku.toString()].unitprice = unitPrice;
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
}
|
| 17871 |
manish.sha |
167 |
$.each( cartItems, function(itemId,value){
|
|
|
168 |
if(value['quantity']>0){
|
|
|
169 |
totalSkus = totalSkus +1;
|
|
|
170 |
}
|
|
|
171 |
});
|
| 17766 |
manish.sha |
172 |
cartDetailsObj.totalCartValue = totalCartValue;
|
| 17871 |
manish.sha |
173 |
cartDetailsObj.totalSkus = totalSkus;
|
| 17766 |
manish.sha |
174 |
cartDetailsObj.cartItems = cartItems;
|
|
|
175 |
localStorage.setItem('cart_details',JSON.stringify(cartDetailsObj));
|
|
|
176 |
}
|
|
|
177 |
if(totalCartQuantity > 0){
|
|
|
178 |
$(".pmfooter span.carttotalval").text(numberWithCommas(totalCartValue));
|
|
|
179 |
$(".pmfooter span.badge").text(totalCartQuantity);
|
| 17871 |
manish.sha |
180 |
$(".pmfooter span.carttotalitemsval").text(totalSkus);
|
| 17766 |
manish.sha |
181 |
$(".pmfooter").removeClass('hidden');
|
|
|
182 |
}else{
|
|
|
183 |
$(".pmfooter span.carttotalval").text('0');
|
|
|
184 |
$(".pmfooter span.badge").text('0');
|
| 17871 |
manish.sha |
185 |
$(".pmfooter span.carttotalitemsval").text('0');
|
| 17766 |
manish.sha |
186 |
$(".pmfooter").addClass('hidden');
|
|
|
187 |
}
|
|
|
188 |
});
|
|
|
189 |
|
|
|
190 |
$(document).on('click','.see_more_colors',function(){
|
| 17804 |
manish.sha |
191 |
var id = $(".number-spinner button").data('id');
|
|
|
192 |
$(".morecoloroptions_"+$(this).data('id')+" button:first-child" ).addClass("active");
|
| 17766 |
manish.sha |
193 |
$('.morecoloroptions_'+$(this).data('id')).toggleClass('hidden');
|
|
|
194 |
});
|
|
|
195 |
|
| 17804 |
manish.sha |
196 |
$(document).on('click','.button-checkbox > .btn',function(){
|
|
|
197 |
$(this).addClass('active').siblings().removeClass('active');
|
|
|
198 |
var cart_details = localStorage.getItem('cart_details');
|
|
|
199 |
if(cart_details!=undefined){
|
|
|
200 |
var cartDetailsObj = JSON.parse(cart_details);
|
|
|
201 |
var item = cartDetailsObj.cartItems[$(this).data('id')];
|
|
|
202 |
if(item!=undefined){
|
| 17819 |
manish.sha |
203 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").data('id',$(this).data('id'));
|
|
|
204 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").data('price',parseInt($(this).data('price')));
|
| 17804 |
manish.sha |
205 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").attr('max',parseInt($(this).data('max')));
|
|
|
206 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").val(item.quantity);
|
|
|
207 |
$(".viewproduct span[data-did='"+$(this).data('did')+"']").text(parseInt($(this).data('price')));
|
|
|
208 |
cartDetailsObj.cartItems[$(this).data('id')].unitprice = parseInt($(this).data('price'));
|
|
|
209 |
localStorage.setItem('cart_details',JSON.stringify(cartDetailsObj));
|
|
|
210 |
}else{
|
| 17819 |
manish.sha |
211 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").data('id',$(this).data('id'));
|
|
|
212 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").data('price',parseInt($(this).data('price')));
|
| 17804 |
manish.sha |
213 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").attr('max',parseInt($(this).data('max')));
|
|
|
214 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").val('0');
|
|
|
215 |
$(".viewproduct span[data-did='"+$(this).data('did')+"']").text(parseInt($(this).data('price')));
|
|
|
216 |
}
|
|
|
217 |
}else{
|
| 17819 |
manish.sha |
218 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").data('id',$(this).data('id'));
|
|
|
219 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").data('price',parseInt($(this).data('price')));
|
| 17804 |
manish.sha |
220 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").attr('max',parseInt($(this).data('max')));
|
|
|
221 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").val('0');
|
|
|
222 |
$(".viewproduct span[data-did='"+$(this).data('did')+"']").text(parseInt($(this).data('price')));
|
|
|
223 |
}
|
|
|
224 |
|
| 17766 |
manish.sha |
225 |
});
|
|
|
226 |
|
|
|
227 |
$("#bottomNav").click(function(){
|
| 17919 |
manish.sha |
228 |
$('#loadingModal').modal('show');
|
| 17775 |
manish.sha |
229 |
var url = apihost + 'cartdetails/?user_id='+me;
|
| 17766 |
manish.sha |
230 |
var newForm = $('<form>', {
|
|
|
231 |
'action': url,
|
|
|
232 |
'method':'post'
|
|
|
233 |
}).append($('<input>', {
|
|
|
234 |
'name': 'cart_details',
|
|
|
235 |
'value': localStorage.getItem('cart_details'),
|
|
|
236 |
'type': 'hidden'
|
|
|
237 |
}));
|
|
|
238 |
newForm.submit();
|
|
|
239 |
});
|
|
|
240 |
|
|
|
241 |
function numberWithCommas(x) {
|
|
|
242 |
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
|
243 |
}
|
| 17839 |
manish.sha |
244 |
|
|
|
245 |
$(document).on('click','.radGroup2',function(){
|
|
|
246 |
var pin = $(this).data('pin');
|
|
|
247 |
var add_id = $(this).data('id');
|
| 17882 |
naman |
248 |
|
| 17839 |
manish.sha |
249 |
$('#loadingModal').modal('show');
|
|
|
250 |
$.ajax({
|
|
|
251 |
method: "GET",
|
| 17882 |
naman |
252 |
url: apihost+"shippings/isServicable/"+pin
|
| 17839 |
manish.sha |
253 |
})
|
|
|
254 |
.done(function( msg ) {
|
| 17882 |
naman |
255 |
console.log(msg);
|
| 17839 |
manish.sha |
256 |
$('#loadingModal').modal('hide');
|
|
|
257 |
if(msg== 'true'){
|
|
|
258 |
$('.myaddress').removeClass('addressselect');
|
|
|
259 |
$('#address'+add_id).addClass('addressselect');
|
|
|
260 |
}
|
|
|
261 |
if(msg== 'false'){
|
|
|
262 |
$('#message').empty();
|
|
|
263 |
$('#message').append("Location is not serviceable...");
|
|
|
264 |
$('#message').removeClass('hidden');
|
|
|
265 |
$("input:radio").removeAttr("checked");
|
|
|
266 |
$('.myaddress').removeClass('addressselect');
|
|
|
267 |
setTimeout(function() {
|
|
|
268 |
$('#message').addClass('hidden');
|
|
|
269 |
}, 2000);
|
|
|
270 |
}
|
|
|
271 |
|
|
|
272 |
// alert(msg);
|
|
|
273 |
});
|
|
|
274 |
});
|
|
|
275 |
|
|
|
276 |
$(document).on('click','#showmore',function(){
|
|
|
277 |
$("#showmoreaddressdropdown").toggle();
|
|
|
278 |
if($('#showmore').html() == 'Show More')
|
|
|
279 |
{
|
|
|
280 |
$("#showmore").html('Show Less');
|
|
|
281 |
}
|
|
|
282 |
else if($("#showmore").html() == 'Show Less')
|
|
|
283 |
{
|
|
|
284 |
// $("#showmore").empty();
|
|
|
285 |
$("#showmore").html('Show More');
|
|
|
286 |
}
|
|
|
287 |
});
|
|
|
288 |
|
| 17997 |
naman |
289 |
$(document).on("click", "form input[type=submit]", function() {
|
|
|
290 |
$('#message').empty();
|
|
|
291 |
var name = document.getElementById("name").value;
|
|
|
292 |
var line1 = document.getElementById("line1").value;
|
|
|
293 |
var city = document.getElementById("city").value;
|
|
|
294 |
var phone = document.getElementById("phone").value;
|
|
|
295 |
var state = document.getElementById("state").value;
|
|
|
296 |
var pin = document.getElementById("pin").value;
|
|
|
297 |
var message ="";
|
|
|
298 |
var value = "true";
|
|
|
299 |
if(name == '')
|
|
|
300 |
{
|
|
|
301 |
value = "false";
|
|
|
302 |
message = "Please fill name field!";
|
|
|
303 |
}
|
|
|
304 |
else if(line1 == '')
|
|
|
305 |
{
|
|
|
306 |
value = "false";
|
|
|
307 |
message = "Please fill address field!";
|
|
|
308 |
}
|
|
|
309 |
else if(city == '')
|
|
|
310 |
{
|
|
|
311 |
value = "false";
|
|
|
312 |
message = "Please fill city field!";
|
|
|
313 |
}
|
|
|
314 |
|
|
|
315 |
else if(phone == '')
|
|
|
316 |
{
|
|
|
317 |
value = "false";
|
|
|
318 |
message = "Please fill contact number field!";
|
|
|
319 |
|
|
|
320 |
}
|
| 17882 |
naman |
321 |
|
| 17997 |
naman |
322 |
else if(phone.match(/^\d{10}$/) == null)
|
|
|
323 |
{
|
|
|
324 |
value = "false";
|
|
|
325 |
message = "Invalid contact number";
|
|
|
326 |
}
|
|
|
327 |
|
|
|
328 |
else if(state == '')
|
|
|
329 |
{
|
|
|
330 |
value = "false";
|
|
|
331 |
message = "Please fill state field!";
|
|
|
332 |
}
|
|
|
333 |
else if(pin == '')
|
|
|
334 |
{
|
|
|
335 |
|
|
|
336 |
value = "false";
|
|
|
337 |
message = "Please fill pin field!";
|
|
|
338 |
}
|
|
|
339 |
else if(pin.match(/^\d{6}$/) == null)
|
|
|
340 |
{
|
|
|
341 |
value = "false";
|
|
|
342 |
message = "Invalid contact number";
|
|
|
343 |
}
|
|
|
344 |
|
|
|
345 |
if(value == "false")
|
|
|
346 |
{
|
|
|
347 |
$('#message').append(message);
|
|
|
348 |
$('#message').removeClass('hidden');
|
|
|
349 |
setTimeout(function() {
|
|
|
350 |
$('#message').addClass('hidden');
|
|
|
351 |
}, 2000);
|
|
|
352 |
return false;
|
|
|
353 |
}
|
|
|
354 |
else{
|
|
|
355 |
|
| 17932 |
amit.gupta |
356 |
$("input[type=submit]", $(this).parents("form")).removeAttr("clicked");
|
|
|
357 |
$(this).attr("clicked", "true");
|
| 17997 |
naman |
358 |
}
|
|
|
359 |
|
| 17932 |
amit.gupta |
360 |
});
|
| 17882 |
naman |
361 |
|
| 17932 |
amit.gupta |
362 |
$(document).on('submit', '#form2', function(e){
|
| 17997 |
naman |
363 |
var payOption = $("input[type=submit][clicked=true]").data('name');
|
|
|
364 |
var formData = {
|
| 17882 |
naman |
365 |
'name' : $('#name').val(),
|
|
|
366 |
'line1' : $('#line1').val(),
|
| 17997 |
naman |
367 |
'city' : $('#city').val(),
|
|
|
368 |
'phone' : $('#phone').val(),
|
|
|
369 |
'state' : $('#state').val(),
|
|
|
370 |
'pin' : $('#pin').val()
|
| 17882 |
naman |
371 |
};
|
| 17916 |
amit.gupta |
372 |
$.ajax(
|
| 17997 |
naman |
373 |
{
|
|
|
374 |
method: "POST",
|
|
|
375 |
url: apihost + "shippings/submitcheck",
|
|
|
376 |
data: formData,
|
|
|
377 |
},'json')
|
|
|
378 |
.done(function(msg){
|
|
|
379 |
if(msg==''){
|
|
|
380 |
window.location.replace(apihost + "shippings/index/"+msg);
|
|
|
381 |
} else {
|
|
|
382 |
if(payOption=='cod'){
|
|
|
383 |
confirmCheckout(msg);
|
|
|
384 |
} else if (payOption=='other_option'){
|
|
|
385 |
confirmPrepaid(msg);
|
|
|
386 |
}
|
|
|
387 |
}
|
|
|
388 |
});
|
|
|
389 |
return false;
|
|
|
390 |
|
| 17916 |
amit.gupta |
391 |
});
|
| 17882 |
naman |
392 |
|
| 17893 |
amit.gupta |
393 |
function confirmPrepaid(addressid){
|
| 17919 |
manish.sha |
394 |
if (typeof addressid=="undefined"){
|
| 17893 |
amit.gupta |
395 |
addressid=$("input.css-checkbox:checked").val();
|
|
|
396 |
}
|
| 17987 |
manish.sha |
397 |
if (addressid==undefined || typeof addressid=="undefined"){
|
|
|
398 |
$('#loadingModal').modal('hide');
|
|
|
399 |
$('#message').empty();
|
|
|
400 |
$('#message').append("Please select an address...");
|
|
|
401 |
$('#message').removeClass('hidden');
|
|
|
402 |
setTimeout(function() {
|
|
|
403 |
$('#message').addClass('hidden');
|
|
|
404 |
}, 2000);
|
|
|
405 |
return;
|
|
|
406 |
}
|
|
|
407 |
|
| 17882 |
naman |
408 |
var url = apihost + 'checkout/?user_id='+me+'&cod=0';
|
| 17871 |
manish.sha |
409 |
var newForm = $('<form>', {
|
|
|
410 |
'action': url,
|
|
|
411 |
'method':'post'
|
|
|
412 |
}).append($('<input>', {
|
|
|
413 |
'name': 'addressid',
|
| 17893 |
amit.gupta |
414 |
'value': addressid,
|
| 17871 |
manish.sha |
415 |
'type': 'hidden'
|
| 17882 |
naman |
416 |
})).append($('<input>', {
|
|
|
417 |
'name': 'cart_details',
|
|
|
418 |
'value': localStorage.getItem('cart_details'),
|
|
|
419 |
'type': 'hidden'
|
| 17871 |
manish.sha |
420 |
}));
|
|
|
421 |
newForm.submit();
|
| 17882 |
naman |
422 |
}
|
| 17871 |
manish.sha |
423 |
|
| 17893 |
amit.gupta |
424 |
function confirmCheckout(addressid){
|
| 17882 |
naman |
425 |
var url = apihost + 'checkout/?user_id='+me+'&cod=1';
|
| 17919 |
manish.sha |
426 |
if (typeof addressid=="undefined"){
|
| 17893 |
amit.gupta |
427 |
addressid=$("input.css-checkbox:checked").val();
|
|
|
428 |
}
|
| 17987 |
manish.sha |
429 |
if (addressid==undefined || typeof addressid=="undefined"){
|
|
|
430 |
$('#loadingModal').modal('hide');
|
|
|
431 |
$('#message').empty();
|
|
|
432 |
$('#message').append("Please select an address...");
|
|
|
433 |
$('#message').removeClass('hidden');
|
|
|
434 |
setTimeout(function() {
|
|
|
435 |
$('#message').addClass('hidden');
|
|
|
436 |
}, 2000);
|
|
|
437 |
return;
|
|
|
438 |
}
|
|
|
439 |
|
| 17871 |
manish.sha |
440 |
var newForm = $('<form>', {
|
|
|
441 |
'action': url,
|
|
|
442 |
'method':'post'
|
|
|
443 |
}).append($('<input>', {
|
|
|
444 |
'name': 'addressid',
|
| 17893 |
amit.gupta |
445 |
'value': addressid,
|
| 17871 |
manish.sha |
446 |
'type': 'hidden'
|
|
|
447 |
}));
|
|
|
448 |
newForm.submit();
|
| 17882 |
naman |
449 |
}
|
| 17871 |
manish.sha |
450 |
|
| 17947 |
manish.sha |
451 |
$(document).on('click','.confirmprepaid', function(){
|
| 17919 |
manish.sha |
452 |
$('#loadingModal').modal('show');
|
|
|
453 |
confirmPrepaid();
|
|
|
454 |
});
|
|
|
455 |
$(document).on('click','button.confirmcheckout', function(){
|
|
|
456 |
$('#loadingModal').modal('show');
|
|
|
457 |
confirmCheckout();
|
|
|
458 |
});
|
|
|
459 |
|
| 17766 |
manish.sha |
460 |
/*
|
|
|
461 |
$('.button-checkbox').each(function () {
|
|
|
462 |
|
|
|
463 |
// Settings
|
|
|
464 |
var $widget = $(this),
|
|
|
465 |
$button = $widget.find('button'),
|
|
|
466 |
$checkbox = $widget.find('input:checkbox'),
|
|
|
467 |
color = $button.data('color'),
|
|
|
468 |
settings = {
|
|
|
469 |
on: {
|
|
|
470 |
icon: 'glyphicon glyphicon-check'
|
|
|
471 |
},
|
|
|
472 |
off: {
|
|
|
473 |
icon: 'glyphicon glyphicon-unchecked'
|
|
|
474 |
}
|
|
|
475 |
};
|
|
|
476 |
|
|
|
477 |
// Event Handlers
|
|
|
478 |
$button.on('click', function () {
|
|
|
479 |
$checkbox.prop('checked', !$checkbox.is(':checked'));
|
|
|
480 |
$checkbox.triggerHandler('change');
|
|
|
481 |
updateDisplay();
|
|
|
482 |
});
|
|
|
483 |
$checkbox.on('change', function () {
|
|
|
484 |
updateDisplay();
|
|
|
485 |
});
|
|
|
486 |
|
|
|
487 |
// Actions
|
|
|
488 |
function updateDisplay() {
|
|
|
489 |
var isChecked = $checkbox.is(':checked');
|
|
|
490 |
|
|
|
491 |
// Set the button's state
|
|
|
492 |
$button.data('state', (isChecked) ? "on" : "off");
|
|
|
493 |
|
|
|
494 |
// Set the button's icon
|
|
|
495 |
$button.find('.state-icon')
|
|
|
496 |
.removeClass()
|
|
|
497 |
.addClass('state-icon ' + settings[$button.data('state')].icon);
|
|
|
498 |
|
|
|
499 |
// Update the button's color
|
|
|
500 |
if (isChecked) {
|
|
|
501 |
$button
|
|
|
502 |
.removeClass('btn-default')
|
|
|
503 |
.addClass('colorbtn active');
|
|
|
504 |
}
|
|
|
505 |
else {
|
|
|
506 |
$button
|
|
|
507 |
.removeClass('colorbtn active')
|
|
|
508 |
.addClass('btn-default');
|
|
|
509 |
}
|
|
|
510 |
}
|
|
|
511 |
|
|
|
512 |
// Initialization
|
|
|
513 |
function init() {
|
|
|
514 |
|
|
|
515 |
updateDisplay();
|
|
|
516 |
|
|
|
517 |
// Inject the icon if applicable
|
|
|
518 |
if ($button.find('.state-icon').length == 0) {
|
|
|
519 |
$button.prepend('<i class="state-icon ' + settings[$button.data('state')].icon + '"></i>');
|
|
|
520 |
}
|
|
|
521 |
}
|
|
|
522 |
init();
|
|
|
523 |
});*/
|