-
Notifications
You must be signed in to change notification settings - Fork 0
/
prg_main.js
2765 lines (1671 loc) · 72.2 KB
/
prg_main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
$(document).ready(function(){
//Starting
category(); //calling defined method
brand();
product();
filter_category_list();
particular_prd_view();
// get the today date
today = (new Date()).toISOString().split('T')[0];
//today date applied to bankdeposit
$("#de_datetxt").val(today);
//category list request
function category(){
$.ajax({
url : "action.php",
method : "POST",
data : {category:1},
success : function(data){
$("#get_category").html(data);
}
})
}
//category list at filter
function filter_category_list(){
$.ajax({
url : "action.php",
method : "POST",
data : {filter_category_list_item:1},
success : function(data){
$("#filter_category").html(data);
}
})
}
//brand list request
function brand(){
$.ajax({
url : "action.php",
method : "POST",
data : {brand:1},
success : function(data){
$("#get_brand").html(data);
}
})
}
//product list request
function product(){
$.ajax({
url : "action.php",
method : "POST",
data : {product:1},
success : function(data){
$("#get_product").html(data);
}
})
}
//filter by category
$("body").delegate("#category","click",function(event){
event.preventDefault();
var cid= $(this).attr('cid');
$.ajax({
url : "action.php",
method : "POST",
data : {get_selected_category:1,selected_cid:cid},// get_selected_category - req ,selected_cid passing
success : function(data){
$("#get_product").html(data);
}
})
})
//filter by brand
$("body").delegate("#brand","click",function(event){
event.preventDefault();
var bid= $(this).attr('bid');
$.ajax({
url : "action.php",
method : "POST",
data : {get_selected_brand:1,selected_bid:bid},// get_selected_brand - req ,selected_bid passing
success : function(data){
$("#get_product").html(data);
}
})
})
//filter by search keywords using search btn
$("#search_btn").click(function(){
var url = new URL(document.URL);
var search_params = url.searchParams;
var keywords = search_params.get('srch');
var currentURL = window.location.pathname;
var check_page_name =currentURL.includes("index.php");
var check_page_name_2 =currentURL.includes("index_filter.php");
var check_page_name_3 =currentURL.includes("profile.php");
var check_page_name_4 =currentURL.includes("profile_filter.php");
var check_page_name_5 =currentURL.includes("unreg_product_view.php");
var keywords = search_params.get('srch');
if(keywords != '')
{
keywords= $("#search_txt").val();
// index - index filter
if((check_page_name==true && keywords!="" ) || ( currentURL == "/project37/" && keywords!=""))
{
window.open("index_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
// index filter - index
if(check_page_name_2==true && keywords=="")
{
window.open("index.php","_self");
}
else if(check_page_name_2==true && keywords!="")
{
window.open("index_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
//profile - profile filter
if(check_page_name_3==true && keywords!="")
{
window.open("profile_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
//profile filter - profile
if(check_page_name_4==true & keywords=="")
{
window.open("profile.php","_self");
}
else if(check_page_name_4==true && keywords!="")
{
window.open("profile_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
// index - index filter
if(check_page_name ==false && check_page_name_2==false && check_page_name_3 ==false && check_page_name_4 ==false && check_page_name_5 ==false && currentURL != "/project37/" && keywords !="" )
{
window.open("profile_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
if(check_page_name_5 ==true && keywords!="")
{
window.open("index_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
}
}
)
//filter by search keywords with press enter key in txt box
$('#search_txt').keypress(function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
var url = new URL(document.URL);
var search_params = url.searchParams;
var keywords = search_params.get('srch');
var currentURL = window.location.pathname;
var check_page_name =currentURL.includes("index.php");
var check_page_name_2 =currentURL.includes("index_filter.php");
var check_page_name_3 =currentURL.includes("profile.php");
var check_page_name_4 =currentURL.includes("profile_filter.php");
var check_page_name_5 =currentURL.includes("unreg_product_view.php");
var keywords = search_params.get('srch');
if(keycode == 13) //enter
{
keywords= $("#search_txt").val();
// index - index filter
if((check_page_name==true && keywords!="" ) || ( currentURL == "/project37/" && keywords!=""))
{
window.open("index_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
// index filter - index
if(check_page_name_2==true && keywords=="")
{
window.open("index.php","_self");
}
else if(check_page_name_2==true && keywords!="")
{
window.open("index_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
//profile - profile filter
if(check_page_name_3==true && keywords!="")
{
window.open("profile_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
//profile filter - profile
if(check_page_name_4==true & keywords=="")
{
window.open("profile.php","_self");
}
else if(check_page_name_4==true && keywords!="")
{
window.open("profile_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
// index - index filter
if(check_page_name ==false && check_page_name_2==false && check_page_name_3 ==false && check_page_name_4 ==false && check_page_name_5 ==false && currentURL != "/project37/" && keywords !="" )
{
window.open("profile_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
if(check_page_name_5 ==true && keywords!="")
{
window.open("index_filter.php?srch="+keywords+"&cat=0&brd=0&lprice=0&hprice=0&rate=0","_self");
}
}
});
//category filter
$('body').delegate('#filter_category_btn','click',function() {
var url = new URL(document.URL);
var search_params = url.searchParams;
var search_val = search_params.get('srch');
var cid= $(this).attr('cid');
var brd_val = search_params.get('brd');
var lprice_val= search_params.get('lprice');
var hprice_val = search_params.get('hprice');
var rate_val = search_params.get('rate');
var currentURL = window.location.pathname;
var check_page_name =currentURL.includes("index_filter.php");
if(check_page_name == true)
{
page_filter="index_filter";
}
else
{
page_filter="profile_filter";
}
window.history.pushState('page2', 'Title', "/project37/"+page_filter+".php?srch="+search_val+"&cat="+cid+"&brd="+brd_val+"&lprice="+lprice_val+"&hprice="+hprice_val+"&rate="+rate_val+"");
prodcuct_multiple_filter();
// window.open;
// window.location.href = ("");
})
//brand filter
$('body').delegate('#filter_brand_btn','click',function() {
var url = new URL(document.URL);
var search_params = url.searchParams;
var search_val = search_params.get('srch');
var cid = search_params.get('cat');
var brd_val = $(this).attr('bid');
var lprice_val= search_params.get('lprice');
var hprice_val = search_params.get('hprice');
var rate_val = search_params.get('rate');
var currentURL = window.location.pathname;
var check_page_name =currentURL.includes("index_filter.php");
if(check_page_name == true)
{
page_filter="index_filter";
}
else
{
page_filter="profile_filter";
}
window.history.pushState('page2', 'Title', "/project37/"+page_filter+".php?srch="+search_val+"&cat="+cid+"&brd="+brd_val+"&lprice="+lprice_val+"&hprice="+hprice_val+"&rate="+rate_val+"");
prodcuct_multiple_filter();
})
$('body').delegate('#feedbackstrs','click',function() {
var url = new URL(document.URL);
var search_params = url.searchParams;
var search_val = search_params.get('srch');
var cid = search_params.get('cat');
var brd_val = search_params.get('brd');
var lprice_val= search_params.get('lprice');
var hprice_val = search_params.get('hprice');
var rate_val = $(this).attr('startval');
var currentURL = window.location.pathname;
var check_page_name =currentURL.includes("index_filter.php");
if(check_page_name == true)
{
page_filter="index_filter";
}
else
{
page_filter="profile_filter";
}
window.history.pushState('page2', 'Title', "/project37/"+page_filter+".php?srch="+search_val+"&cat="+cid+"&brd="+brd_val+"&lprice="+lprice_val+"&hprice="+hprice_val+"&rate="+rate_val+"");
prodcuct_multiple_filter();
})
$('body').delegate('#price_val_btn','click',function() {
var url = new URL(document.URL);
var search_params = url.searchParams;
var search_val = search_params.get('srch');
var cid = search_params.get('cat');
var brd_val = search_params.get('brd');
var lprice_val = $('#lpriceid').val();
var hprice_val = $('#hpriceid').val();
var rate_val = search_params.get('rate');
if(hprice_val=="")
{
hprice_val=0;
}
if(lprice_val=="")
{
lprice_val=0;
}
var currentURL = window.location.pathname;
var check_page_name =currentURL.includes("index_filter.php");
if(check_page_name == true)
{
page_filter="index_filter";
}
else
{
page_filter="profile_filter";
}
window.history.pushState('page2', 'Title', "/project37/"+page_filter+".php?srch="+search_val+"&cat="+cid+"&brd="+brd_val+"&lprice="+lprice_val+"&hprice="+hprice_val+"&rate="+rate_val+"");
prodcuct_multiple_filter();
})
search_prd_txt();
function search_prd_txt(){
var url = new URL(document.URL);
var search_params = url.searchParams;
var keywords = search_params.get('srch');//search value
var currentURL = window.location.pathname;
var check_page_name =currentURL.includes("profile.php");
if(keywords!='')
{
$('#search_txt').val(keywords); //URL Search to serach text box
$.ajax({
url : "action.php",
method : "POST",
data : {get_search:1,keywords:keywords},
success : function(data){
$("#get_product").html(data);
}
})
}
else
{
window.open("index_filter.php","_self");
}
}
//customer resgistration form
$('#customer_reg_form').on('submit',function(event){
event.preventDefault(); //prevent from the submision
//get the value from form using post method
var fname = $('#fname').val();
var lname = $('#lname').val();
var email = $('#email').val();
var phone = $('#phone').val();
var passwords = $('#password').val();
var repassword = $('#repassword').val();
var address = $('#address').val();
var city = $('#city').val();
var postal = $('#postal').val();
//default validation values
var nameformat = /^[A-Za-z]+$/;;
var emailformat = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var phonenumberformat= /^\d{11}$/;
var postalcodeformat= /^\d{5}$/;
if(fname == "" || lname == "" || email == "" || phone == "" || passwords == "" || repassword == "" || address == "" || city == "" || postal == "" )
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Dear Customer !</strong> Please fill all the fields to continue<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if(!nameformat.test(fname))
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Incorrect First Name !</strong><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if(!nameformat.test(lname))
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Incorrect Last Name !</strong><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if(fname == lname)
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Firstname and Lastname </strong> are the same!<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if(!emailformat.test(email))
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Incorrect Email!</strong><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if(!phonenumberformat.test(phone))
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Incorrect Phone Number!</strong><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if(phone.length <= 10 )
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Incorrect Phone Number!</strong> Please inlude 94<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if( passwords.length < 8 )
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Please enter a password of 6 - 20 characters !</strong> <button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if( passwords != repassword)
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Password doesn't match with each other</strong> <button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if(!postalcodeformat.test(postal))
{
$('#cus_alert_msg').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Incorrect Postal code!</strong><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else{ // if no errors
$.ajax({
url : "action.php",
method : "POST",
data : {cus_reg:1,fname:fname,lname:lname,email:email,phone:phone,passwords:passwords,address:address,city:city,postal:postal},
success : function(data){
$('#cus_alert_msg').html(data);
}
})
}
});
//customer login verification code
$("#login_page_login_btn").click(function(){
event.preventDefault(); //prevent from the submision
var lg_email_txt = $('#lg_email_txt').val(); //getting user enterted email id from login text box
var lg_password_txt = $('#lg_password_txt').val(); //getting user enterted password from login text box
var emailformat = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if(lg_email_txt == "" || lg_password_txt == "") //verification for empty textbox
{
//empty alert message
$('#cus_reg_alert_msg_login').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss><strong>Dear Customer!</strong> Please fill all the fields <button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else if(!emailformat.test(lg_email_txt)) //verification for email id formate
{
$('#cus_reg_alert_msg_login').html("<div class='alert alert-danger alert-dismissible fade show' role='alert' data-auto-dismiss>Incorrect <strong>Email!</strong><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>")
}
else{
$.ajax({
url : "action.php", //parsing the data to action PHP page
method : "POST", //using post method to parse
data : {userLogin:1,useremail:lg_email_txt,userpassword:lg_password_txt}, //parse the data with different param
success : function(data){
$('#cus_reg_alert_msg_login').html(data); // output mmessage
}
})
}})
//login model hide when click create account button
$('body').delegate('#create_form_model','click',function() {
$('#customer_login_model').modal('hide');
})
cart_prd_count();
cart_nav_list_total();
//product add to card
$("body").delegate("#particular_product_btn","click",function(){
event.preventDefault();
var pid= $(this).attr('pid'); //get the value from our self pid attribute pid
var product_qty_txt = $("#qty-"+pid).val();
$.ajax({
url : "action.php",
method : "POST",
data : {add_to_card:1,product_id:pid,product_qty:product_qty_txt}, // add_to_card -method name , product_id - opaasing value to php
success : function(data){
$('#show_msg').html(data);
card_container_btn();
$("#qty-"+pid).val("1");
}
})
})
// particular product search button click
$("body").delegate("#particular_product_search_btn","click",function(){
event.preventDefault();
var pid_val= $(this).attr('pid'); //get the value from our self pid attribute pid
var session_val= $(this).attr('session_val'); //get the value from our self pid attribute pid
$.ajax({
url : "action.php",
method : "POST",
data : {product_available_verify:1,product_id:pid_val},
success : function(data){
//if product is active
if(data==1)
{
if(session_val=="")
{
window.open("unreg_product_view.php?pid="+pid_val+"","_self");
}
else
{
window.open("product_view.php?pid="+pid_val+"","_self");
}
}
else //if product is inactive
{
$('#prodcuct_not_available_msg_model').modal('show');
setTimeout(function(){// wait for 2 secs
location.reload(); // then reload the page.
}, 2000);
product_longer_available_msg();
function product_longer_available_msg(){
$('.card-body').html('<center>Sorry, this product is no longer available</center>');
}
}
}
})
})
/* dont kow why we used
atv();
function atv()
{
var url = new URL(document.URL);
var search_params = url.searchParams;
var product_id = search_params.get('pid');
$.ajax({
url : "action.php",
method : "GET",
data : {prd_view_page:1,pid:product_id}, // get the added product into cart
success : function(data){
$('#particular_prd_view').html(data);
}
})
}*/
card_container_btn();
//added product list container also used for online payment
function card_container_btn(){
var offer_txt = $("#offer_msg_at_profile").html();
$.ajax({
url : "action.php",
method : "POST",
data : {get_added_products_into_card:1,offer:offer_txt}, // get the added product into cart
success : function(data){
$('#all_product_list').html(data);
}
})
cart_prd_count();
cart_nav_list_total();
}
function cart_prd_count(){
$.ajax({
url : "action.php",
method : "POST",
data : {cart_count:1}, // get the added product into cart
success : function(data){
$('#badge').html(data);
$('#badge_in_nave_manue').html(data);
}
})
}
cart_nav_list_total();
function cart_nav_list_total(){
$.ajax({
url : "action.php",
method : "POST",
data : {nav_list_total:1}, // get the order's total val
success : function(data){
$('#nav_list_total_val').html(data);
}
})
}
orderd_prd_count(); //orders count nave menue
function orderd_prd_count(){
$.ajax({
url : "action.php",
method : "POST",
data : {orderd_prd_count:1}, // get the added product into cart
success : function(data){
$('#orders_badge_in_nave_manue').html(data);
}
})
}
//get all ordered prouct in card card page
card_page_list();
function card_page_list(){
$.ajax({
url : "action.php",
method : "POST",
data : {card_page_list:1}, // get the added product into cart
success : function(data){
$('#card_page_list').html(data);
cart_nav_list_total();
}
})
}
// used to clear all model when close
$('.modal').on('hidden.bs.modal', function(){
$(this).find('form')[0].reset();
});
//product add to card
$("body").delegate(".qty","input",function(){
event.preventDefault();
var pid= $(this).attr('pid'); //get the value from our self pid attribute pid
var product_qty = $("#qty-"+pid).val();
var product_price = $("#price-"+pid).text();
var product_total = product_qty * product_price;
$("#total-"+pid).text(product_total);
})
//remove the product from card
$("body").delegate(".remove","click",function(){
event.preventDefault();
var pid= $(this).attr('remove_id'); //get the value from our selected product id
var new_product_qty = $("#qty-"+pid).val();
$.ajax({
url : "action.php",
method : "POST",
data : {removefromcart:1,remove_product_id:pid,new_qty:new_product_qty}, // pass the arguments
success : function(data){
$('#cart_msg').html(data);
card_page_list(); //no need to refresh it will be load all the orderd products
cart_prd_count(); // if i remive card qty decrease function call
card_container_btn();// if i remive card list update
cart_nav_list_total();
}
})
})
//Update the product from card
$("body").delegate(".update","click",function(){
event.preventDefault();
var pid= $(this).attr('update_id'); //get the value from our self pid attribute pid
var product_qty = $("#qty-"+pid).val();
var customer_note_txt =$("#note-"+pid).val();
var product_price = $("#price-"+pid).text();
var product_total = product_qty * product_price;
$.ajax({
url : "action.php",
method : "POST",
data : {updatefromcart:1,update_product_id:pid,new_qty:product_qty,current_product_total:product_total,customer_note:customer_note_txt},
success : function(data){
$('#cart_msg').html(data);
card_page_list();
card_container_btn();
}