| 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');
|
| 18419 |
naman |
66 |
oldValue = btn.closest('.number-spinner').find('input').val().trim();
|
| 17766 |
manish.sha |
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;
|
| 18419 |
naman |
84 |
var sku = btn.attr('data-id');
|
| 17766 |
manish.sha |
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');
|
| 18419 |
naman |
201 |
if($('.morecoloroptions_'+$(this).data('id')+' .button-checkbox button').hasClass('active'))
|
|
|
202 |
{}
|
|
|
203 |
else{
|
|
|
204 |
$(".morecoloroptions_"+$(this).data('id')+" button:first-child" ).addClass("active");
|
|
|
205 |
}
|
|
|
206 |
|
| 17766 |
manish.sha |
207 |
$('.morecoloroptions_'+$(this).data('id')).toggleClass('hidden');
|
|
|
208 |
});
|
|
|
209 |
|
| 17804 |
manish.sha |
210 |
$(document).on('click','.button-checkbox > .btn',function(){
|
|
|
211 |
$(this).addClass('active').siblings().removeClass('active');
|
|
|
212 |
var cart_details = localStorage.getItem('cart_details');
|
| 18419 |
naman |
213 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").prop("disabled", false);
|
| 17804 |
manish.sha |
214 |
if(cart_details!=undefined){
|
|
|
215 |
var cartDetailsObj = JSON.parse(cart_details);
|
|
|
216 |
var item = cartDetailsObj.cartItems[$(this).data('id')];
|
|
|
217 |
if(item!=undefined){
|
| 18419 |
naman |
218 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").attr('style', 'border: 0');
|
|
|
219 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").attr('data-id',$(this).data('id'));
|
|
|
220 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").attr('data-price',parseInt($(this).data('price')));
|
| 17804 |
manish.sha |
221 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").attr('max',parseInt($(this).data('max')));
|
|
|
222 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").val(item.quantity);
|
|
|
223 |
$(".viewproduct span[data-did='"+$(this).data('did')+"']").text(parseInt($(this).data('price')));
|
|
|
224 |
cartDetailsObj.cartItems[$(this).data('id')].unitprice = parseInt($(this).data('price'));
|
|
|
225 |
localStorage.setItem('cart_details',JSON.stringify(cartDetailsObj));
|
|
|
226 |
}else{
|
| 18419 |
naman |
227 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").attr('style', 'border: 0');
|
|
|
228 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").attr('data-id',$(this).data('id'));
|
|
|
229 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").attr('data-price',parseInt($(this).data('price')));
|
| 17804 |
manish.sha |
230 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").attr('max',parseInt($(this).data('max')));
|
|
|
231 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").val('0');
|
|
|
232 |
$(".viewproduct span[data-did='"+$(this).data('did')+"']").text(parseInt($(this).data('price')));
|
|
|
233 |
}
|
|
|
234 |
}else{
|
| 18419 |
naman |
235 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").attr('style', 'border: 0');
|
|
|
236 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").attr('data-id',$(this).data('id'));
|
|
|
237 |
$(".number-spinner button[data-did='"+$(this).data('did')+"']").attr('data-price',parseInt($(this).data('price')));
|
| 17804 |
manish.sha |
238 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").attr('max',parseInt($(this).data('max')));
|
|
|
239 |
$(".number-spinner input[data-did='"+$(this).data('did')+"']").val('0');
|
|
|
240 |
$(".viewproduct span[data-did='"+$(this).data('did')+"']").text(parseInt($(this).data('price')));
|
|
|
241 |
}
|
|
|
242 |
|
| 17766 |
manish.sha |
243 |
});
|
|
|
244 |
|
| 18242 |
naman |
245 |
$(document).on('click','#bottomNav',function(){
|
| 17919 |
manish.sha |
246 |
$('#loadingModal').modal('show');
|
| 17775 |
manish.sha |
247 |
var url = apihost + 'cartdetails/?user_id='+me;
|
| 17766 |
manish.sha |
248 |
var newForm = $('<form>', {
|
|
|
249 |
'action': url,
|
|
|
250 |
'method':'post'
|
|
|
251 |
}).append($('<input>', {
|
|
|
252 |
'name': 'cart_details',
|
|
|
253 |
'value': localStorage.getItem('cart_details'),
|
|
|
254 |
'type': 'hidden'
|
|
|
255 |
}));
|
|
|
256 |
newForm.submit();
|
|
|
257 |
});
|
|
|
258 |
|
|
|
259 |
function numberWithCommas(x) {
|
|
|
260 |
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
|
261 |
}
|
| 17839 |
manish.sha |
262 |
|
|
|
263 |
$(document).on('click','.radGroup2',function(){
|
|
|
264 |
var pin = $(this).data('pin');
|
|
|
265 |
var add_id = $(this).data('id');
|
| 17882 |
naman |
266 |
|
| 17839 |
manish.sha |
267 |
$('#loadingModal').modal('show');
|
|
|
268 |
$.ajax({
|
|
|
269 |
method: "GET",
|
| 17882 |
naman |
270 |
url: apihost+"shippings/isServicable/"+pin
|
| 17839 |
manish.sha |
271 |
})
|
|
|
272 |
.done(function( msg ) {
|
| 17882 |
naman |
273 |
console.log(msg);
|
| 17839 |
manish.sha |
274 |
$('#loadingModal').modal('hide');
|
|
|
275 |
if(msg== 'true'){
|
|
|
276 |
$('.myaddress').removeClass('addressselect');
|
|
|
277 |
$('#address'+add_id).addClass('addressselect');
|
|
|
278 |
}
|
|
|
279 |
if(msg== 'false'){
|
|
|
280 |
$('#message').empty();
|
|
|
281 |
$('#message').append("Location is not serviceable...");
|
|
|
282 |
$('#message').removeClass('hidden');
|
|
|
283 |
$("input:radio").removeAttr("checked");
|
|
|
284 |
$('.myaddress').removeClass('addressselect');
|
|
|
285 |
setTimeout(function() {
|
|
|
286 |
$('#message').addClass('hidden');
|
|
|
287 |
}, 2000);
|
|
|
288 |
}
|
|
|
289 |
|
|
|
290 |
// alert(msg);
|
|
|
291 |
});
|
|
|
292 |
});
|
|
|
293 |
|
|
|
294 |
$(document).on('click','#showmore',function(){
|
|
|
295 |
$("#showmoreaddressdropdown").toggle();
|
|
|
296 |
if($('#showmore').html() == 'Show More')
|
|
|
297 |
{
|
|
|
298 |
$("#showmore").html('Show Less');
|
|
|
299 |
}
|
|
|
300 |
else if($("#showmore").html() == 'Show Less')
|
|
|
301 |
{
|
|
|
302 |
// $("#showmore").empty();
|
|
|
303 |
$("#showmore").html('Show More');
|
|
|
304 |
}
|
|
|
305 |
});
|
|
|
306 |
|
| 17997 |
naman |
307 |
$(document).on("click", "form input[type=submit]", function() {
|
|
|
308 |
$('#message').empty();
|
|
|
309 |
var name = document.getElementById("name").value;
|
|
|
310 |
var line1 = document.getElementById("line1").value;
|
|
|
311 |
var city = document.getElementById("city").value;
|
|
|
312 |
var phone = document.getElementById("phone").value;
|
|
|
313 |
var state = document.getElementById("state").value;
|
|
|
314 |
var pin = document.getElementById("pin").value;
|
|
|
315 |
var message ="";
|
|
|
316 |
var value = "true";
|
|
|
317 |
if(name == '')
|
|
|
318 |
{
|
|
|
319 |
value = "false";
|
|
|
320 |
message = "Please fill name field!";
|
|
|
321 |
}
|
|
|
322 |
else if(line1 == '')
|
|
|
323 |
{
|
|
|
324 |
value = "false";
|
|
|
325 |
message = "Please fill address field!";
|
|
|
326 |
}
|
|
|
327 |
else if(city == '')
|
|
|
328 |
{
|
|
|
329 |
value = "false";
|
|
|
330 |
message = "Please fill city field!";
|
|
|
331 |
}
|
|
|
332 |
|
|
|
333 |
else if(phone == '')
|
|
|
334 |
{
|
|
|
335 |
value = "false";
|
|
|
336 |
message = "Please fill contact number field!";
|
|
|
337 |
|
|
|
338 |
}
|
| 17882 |
naman |
339 |
|
| 17997 |
naman |
340 |
else if(phone.match(/^\d{10}$/) == null)
|
|
|
341 |
{
|
|
|
342 |
value = "false";
|
|
|
343 |
message = "Invalid contact number";
|
|
|
344 |
}
|
|
|
345 |
|
|
|
346 |
else if(state == '')
|
|
|
347 |
{
|
|
|
348 |
value = "false";
|
|
|
349 |
message = "Please fill state field!";
|
|
|
350 |
}
|
|
|
351 |
else if(pin == '')
|
|
|
352 |
{
|
|
|
353 |
|
|
|
354 |
value = "false";
|
|
|
355 |
message = "Please fill pin field!";
|
|
|
356 |
}
|
|
|
357 |
else if(pin.match(/^\d{6}$/) == null)
|
|
|
358 |
{
|
|
|
359 |
value = "false";
|
| 18001 |
naman |
360 |
message = "Invalid pin number";
|
| 17997 |
naman |
361 |
}
|
|
|
362 |
|
|
|
363 |
if(value == "false")
|
|
|
364 |
{
|
|
|
365 |
$('#message').append(message);
|
|
|
366 |
$('#message').removeClass('hidden');
|
|
|
367 |
setTimeout(function() {
|
|
|
368 |
$('#message').addClass('hidden');
|
|
|
369 |
}, 2000);
|
|
|
370 |
return false;
|
|
|
371 |
}
|
|
|
372 |
else{
|
|
|
373 |
|
| 17932 |
amit.gupta |
374 |
$("input[type=submit]", $(this).parents("form")).removeAttr("clicked");
|
|
|
375 |
$(this).attr("clicked", "true");
|
| 17997 |
naman |
376 |
}
|
|
|
377 |
|
| 17932 |
amit.gupta |
378 |
});
|
| 17882 |
naman |
379 |
|
| 17932 |
amit.gupta |
380 |
$(document).on('submit', '#form2', function(e){
|
| 17997 |
naman |
381 |
var payOption = $("input[type=submit][clicked=true]").data('name');
|
|
|
382 |
var formData = {
|
| 17882 |
naman |
383 |
'name' : $('#name').val(),
|
|
|
384 |
'line1' : $('#line1').val(),
|
| 17997 |
naman |
385 |
'city' : $('#city').val(),
|
|
|
386 |
'phone' : $('#phone').val(),
|
|
|
387 |
'state' : $('#state').val(),
|
|
|
388 |
'pin' : $('#pin').val()
|
| 17882 |
naman |
389 |
};
|
| 17916 |
amit.gupta |
390 |
$.ajax(
|
| 17997 |
naman |
391 |
{
|
|
|
392 |
method: "POST",
|
|
|
393 |
url: apihost + "shippings/submitcheck",
|
|
|
394 |
data: formData,
|
|
|
395 |
},'json')
|
|
|
396 |
.done(function(msg){
|
|
|
397 |
if(msg==''){
|
|
|
398 |
window.location.replace(apihost + "shippings/index/"+msg);
|
|
|
399 |
} else {
|
|
|
400 |
if(payOption=='cod'){
|
|
|
401 |
confirmCheckout(msg);
|
|
|
402 |
} else if (payOption=='other_option'){
|
|
|
403 |
confirmPrepaid(msg);
|
|
|
404 |
}
|
|
|
405 |
}
|
|
|
406 |
});
|
|
|
407 |
return false;
|
|
|
408 |
|
| 17916 |
amit.gupta |
409 |
});
|
| 17882 |
naman |
410 |
|
| 17893 |
amit.gupta |
411 |
function confirmPrepaid(addressid){
|
| 17919 |
manish.sha |
412 |
if (typeof addressid=="undefined"){
|
| 17893 |
amit.gupta |
413 |
addressid=$("input.css-checkbox:checked").val();
|
|
|
414 |
}
|
| 17987 |
manish.sha |
415 |
if (addressid==undefined || typeof addressid=="undefined"){
|
|
|
416 |
$('#loadingModal').modal('hide');
|
|
|
417 |
$('#message').empty();
|
|
|
418 |
$('#message').append("Please select an address...");
|
|
|
419 |
$('#message').removeClass('hidden');
|
|
|
420 |
setTimeout(function() {
|
|
|
421 |
$('#message').addClass('hidden');
|
|
|
422 |
}, 2000);
|
|
|
423 |
return;
|
|
|
424 |
}
|
|
|
425 |
|
| 17882 |
naman |
426 |
var url = apihost + 'checkout/?user_id='+me+'&cod=0';
|
| 17871 |
manish.sha |
427 |
var newForm = $('<form>', {
|
|
|
428 |
'action': url,
|
|
|
429 |
'method':'post'
|
|
|
430 |
}).append($('<input>', {
|
|
|
431 |
'name': 'addressid',
|
| 17893 |
amit.gupta |
432 |
'value': addressid,
|
| 17871 |
manish.sha |
433 |
'type': 'hidden'
|
| 17882 |
naman |
434 |
})).append($('<input>', {
|
|
|
435 |
'name': 'cart_details',
|
|
|
436 |
'value': localStorage.getItem('cart_details'),
|
|
|
437 |
'type': 'hidden'
|
| 17871 |
manish.sha |
438 |
}));
|
|
|
439 |
newForm.submit();
|
| 17882 |
naman |
440 |
}
|
| 17871 |
manish.sha |
441 |
|
| 17893 |
amit.gupta |
442 |
function confirmCheckout(addressid){
|
| 17882 |
naman |
443 |
var url = apihost + 'checkout/?user_id='+me+'&cod=1';
|
| 17919 |
manish.sha |
444 |
if (typeof addressid=="undefined"){
|
| 17893 |
amit.gupta |
445 |
addressid=$("input.css-checkbox:checked").val();
|
|
|
446 |
}
|
| 17987 |
manish.sha |
447 |
if (addressid==undefined || typeof addressid=="undefined"){
|
|
|
448 |
$('#loadingModal').modal('hide');
|
|
|
449 |
$('#message').empty();
|
|
|
450 |
$('#message').append("Please select an address...");
|
|
|
451 |
$('#message').removeClass('hidden');
|
|
|
452 |
setTimeout(function() {
|
|
|
453 |
$('#message').addClass('hidden');
|
|
|
454 |
}, 2000);
|
|
|
455 |
return;
|
|
|
456 |
}
|
|
|
457 |
|
| 17871 |
manish.sha |
458 |
var newForm = $('<form>', {
|
|
|
459 |
'action': url,
|
|
|
460 |
'method':'post'
|
|
|
461 |
}).append($('<input>', {
|
|
|
462 |
'name': 'addressid',
|
| 17893 |
amit.gupta |
463 |
'value': addressid,
|
| 17871 |
manish.sha |
464 |
'type': 'hidden'
|
|
|
465 |
}));
|
|
|
466 |
newForm.submit();
|
| 17882 |
naman |
467 |
}
|
| 17871 |
manish.sha |
468 |
|
| 17947 |
manish.sha |
469 |
$(document).on('click','.confirmprepaid', function(){
|
| 18428 |
manish.sha |
470 |
$('.confirmprepaid').addClass('confirmprepaidDisabled').removeClass('confirmprepaid');
|
| 17919 |
manish.sha |
471 |
$('#loadingModal').modal('show');
|
|
|
472 |
confirmPrepaid();
|
|
|
473 |
});
|
|
|
474 |
$(document).on('click','button.confirmcheckout', function(){
|
| 18428 |
manish.sha |
475 |
$('button.confirmcheckout').prop( "disabled", true );
|
| 17919 |
manish.sha |
476 |
$('#loadingModal').modal('show');
|
|
|
477 |
confirmCheckout();
|
|
|
478 |
});
|
|
|
479 |
|
| 17766 |
manish.sha |
480 |
/*
|
|
|
481 |
$('.button-checkbox').each(function () {
|
|
|
482 |
|
|
|
483 |
// Settings
|
|
|
484 |
var $widget = $(this),
|
|
|
485 |
$button = $widget.find('button'),
|
|
|
486 |
$checkbox = $widget.find('input:checkbox'),
|
|
|
487 |
color = $button.data('color'),
|
|
|
488 |
settings = {
|
|
|
489 |
on: {
|
|
|
490 |
icon: 'glyphicon glyphicon-check'
|
|
|
491 |
},
|
|
|
492 |
off: {
|
|
|
493 |
icon: 'glyphicon glyphicon-unchecked'
|
|
|
494 |
}
|
|
|
495 |
};
|
|
|
496 |
|
|
|
497 |
// Event Handlers
|
|
|
498 |
$button.on('click', function () {
|
|
|
499 |
$checkbox.prop('checked', !$checkbox.is(':checked'));
|
|
|
500 |
$checkbox.triggerHandler('change');
|
|
|
501 |
updateDisplay();
|
|
|
502 |
});
|
|
|
503 |
$checkbox.on('change', function () {
|
|
|
504 |
updateDisplay();
|
|
|
505 |
});
|
|
|
506 |
|
|
|
507 |
// Actions
|
|
|
508 |
function updateDisplay() {
|
|
|
509 |
var isChecked = $checkbox.is(':checked');
|
|
|
510 |
|
|
|
511 |
// Set the button's state
|
|
|
512 |
$button.data('state', (isChecked) ? "on" : "off");
|
|
|
513 |
|
|
|
514 |
// Set the button's icon
|
|
|
515 |
$button.find('.state-icon')
|
|
|
516 |
.removeClass()
|
|
|
517 |
.addClass('state-icon ' + settings[$button.data('state')].icon);
|
|
|
518 |
|
|
|
519 |
// Update the button's color
|
|
|
520 |
if (isChecked) {
|
|
|
521 |
$button
|
|
|
522 |
.removeClass('btn-default')
|
|
|
523 |
.addClass('colorbtn active');
|
|
|
524 |
}
|
|
|
525 |
else {
|
|
|
526 |
$button
|
|
|
527 |
.removeClass('colorbtn active')
|
|
|
528 |
.addClass('btn-default');
|
|
|
529 |
}
|
|
|
530 |
}
|
|
|
531 |
|
|
|
532 |
// Initialization
|
|
|
533 |
function init() {
|
|
|
534 |
|
|
|
535 |
updateDisplay();
|
|
|
536 |
|
|
|
537 |
// Inject the icon if applicable
|
|
|
538 |
if ($button.find('.state-icon').length == 0) {
|
|
|
539 |
$button.prepend('<i class="state-icon ' + settings[$button.data('state')].icon + '"></i>');
|
|
|
540 |
}
|
|
|
541 |
}
|
|
|
542 |
init();
|
|
|
543 |
});*/
|