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