-
Notifications
You must be signed in to change notification settings - Fork 2
/
CheckOut.ascx.vb
1298 lines (1044 loc) · 57.4 KB
/
CheckOut.ascx.vb
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
' --- Copyright (c) notice NevoWeb ---
' Copyright (c) 2008 SARL NevoWeb. www.nevoweb.com. BSD License.
' Author: D.C.Lee
' ------------------------------------------------------------------------
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
' ------------------------------------------------------------------------
' This copyright notice may NOT be removed, obscured or modified without written consent from the author.
' --- End copyright notice ---
Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports NEvoWeb.Modules.NB_Store.SharedFunctions
Imports DotNetNuke.Security.Membership
Namespace NEvoWeb.Modules.NB_Store
Partial Public Class CheckOut
Inherits BaseModule
Implements Entities.Modules.IPortable
Private Stage As String = ""
Private objGateway As New GatewayWrapper
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Dim TemplateText As String = GetStoreSettingText(PortalId, "gateway.template", GetCurrentCulture)
Dim blnLockOnCart As Boolean = GetStoreSettingBoolean(PortalId, "lockstockoncart", GetCurrentCulture)
Dim QtyLimit As Integer = 999999
Dim tmp As String = GetStoreSetting(PortalId, "productqty.limit", GetCurrentCulture)
If IsNumeric(tmp) Then
QtyLimit = CInt(tmp)
End If
dlGateway2.ItemTemplate = New ProductTemplate(TabId, ModuleId, StoreInstallPath, "50", Server.HtmlDecode(TemplateText), False, "", CType(Settings("txtCssBuyButton"), String), 1, -1, "50", "", TabId, UserId, UserInfo, "", "", blnLockOnCart, QtyLimit)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If Not Page.IsPostBack Then
If Not (Request.QueryString("codeid") Is Nothing) Then
'link order and build cart for client.
Dim codeid As String = Request.QueryString("codeid")
Dim objCCtrl As New CartController
objCCtrl.BuildFromSeedOrder(PortalId, codeid)
End If
End If
Dim objCInfo As NB_Store_CartInfo
If Page.IsPostBack Then
If objGateway.GetBankClick(PortalId, Request) Then
GatewayRedirect()
End If
End If
Stage = "1"
If Not (Request.QueryString("stg") Is Nothing) Then
Stage = Request.QueryString("stg")
End If
If CType(Settings("chkHideExtraInfo"), Boolean) Then
plhNoteMsg.Visible = False
txtNoteMsg.Visible = False
End If
If CType(Settings("chkSkipCart"), Boolean) Then
'jump to address input
If Stage = "1" Then Stage = "2"
'hide back button of address page
cmdBack1.Visible = False
End If
If CType(Settings("chkShowStageHeader"), Boolean) Then
phHeader.Controls.Add(New LiteralControl(Server.HtmlDecode(GetStoreSettingText(PortalId, "stgheader" & Stage & ".template", GetCurrentCulture))))
End If
If CType(Settings("chkHideShipInCart"), Boolean) Then
cartlist1.ShippingHidden = True
cartlist2.ShippingHidden = True
End If
pnlAddressDetails.Visible = False
pnlCart.Visible = False
pnlLogin.Visible = False
pnlPayRtn.Visible = False
pnlPromptPay.Visible = False
pnlEmptyCart.Visible = False
Select Case Stage
Case "1" ' cart view (Default)
If CurrentCart.IsCartEmpty(PortalId) Then
DisplayEmptyCart()
Else
HideCartOptions()
If Not Page.IsPostBack Then
objCInfo = CurrentCart.GetCurrentCart(PortalId)
txtVATCode.Text = objCInfo.VATNumber
txtPromoCode.Text = objCInfo.PromoCode
If objCInfo.CountryCode = "" Then
'get special countrycode if set.
objCInfo.CountryCode = GetStoreSetting(PortalId, "shipcountrycode.default", GetCurrentCulture)
If objCInfo.CountryCode = "" Then
'else use merchant country code as default.
objCInfo.CountryCode = GetMerchantCountryCode(PortalId)
End If
CurrentCart.Save(objCInfo)
End If
populateCountryList(PortalId, ddlCountry, objCInfo.CountryCode)
End If
SetUpCartList()
End If
Case "2" ' Address
If CurrentCart.IsCartEmpty(PortalId) Then
DisplayEmptyCart()
ElseIf Not CurrentCart.IsCartAboveMinimum(PortalId) Then
DisplayMinimumCart()
Else
If DisplayLogin() Then
DisplayLoginMsg()
Else
HideCartOptions()
If Not Page.IsPostBack Then
objCInfo = CurrentCart.GetCurrentCart(PortalId)
txtVATCode2.Text = objCInfo.VATNumber
populateAddress()
End If
DisplayExtraDetailMsg()
End If
End If
Case "3" ' Payment Gateway
CurrentCart.ValidateCart(PortalId, UserInfo)
If CurrentCart.IsCartEmpty(PortalId) Then
DisplayEmptyCart()
Else
If Not Page.IsPostBack Then
HideCartOptions()
SetUpOrderList()
'display gateway2
Dim objOInfo As New NB_Store_OrdersInfo
Dim aryList As New ArrayList
Dim objOCtrl As New OrderController
objOInfo = objOCtrl.GetOrder(CurrentCart.GetCurrentCart(PortalId).OrderID)
If Not objOInfo Is Nothing Then
If objOInfo.AlreadyPaid <> 0 Then
cmdCancelOrder.Visible = False
End If
End If
aryList.Add(objOInfo)
dlGateway2.DataSource = aryList
dlGateway2.DataBind()
End If
AddChqGateway()
AddBankGateway()
End If
Case "4" ' AUTO run return for bank
objGateway.AutoResponse(PortalId, Request)
If Not InternalUpdateInterface.Instance() Is Nothing Then
InternalUpdateInterface.Instance.AutoResponse(PortalId, Request)
End If
If Not EventInterface.Instance() Is Nothing Then
EventInterface.Instance.AutoResponse(PortalId, Request)
End If
'support for merchant integrated CC input.
If Not Session("BankHtmlRedirect") Is Nothing Then
If Session("BankHtmlRedirect") <> "" Then
Response.Redirect(EditUrl("RemotePost"))
End If
End If
Case "5" ' completed return
If CurrentCart.IsCartEmpty(PortalId) Then
If Request.QueryString("chq") Is Nothing Then
objGateway.AutoResponse(PortalId, Request) ' put auto response here, for payment providers that return notify on same url as return.
End If
DisplayEmptyCart()
Else
If Not InternalUpdateInterface.Instance() Is Nothing Then
InternalUpdateInterface.Instance.ReturnToStore(PortalId, CurrentCart.GetCurrentCart(PortalId), GetCurrentCulture, Request)
End If
If Not (Request.QueryString("chq") Is Nothing) Then
CompletedChqPayment()
Else
CompletedBankPayment()
End If
End If
End Select
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#Region "Cart View"
#Region "Cart View Events"
Private Sub ddlCountry_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlCountry.SelectedIndexChanged, rblShipMethod.SelectedIndexChanged, rblShipMethod2.SelectedIndexChanged
ReDisplayCart()
End Sub
Private Sub cmdOrder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdOrder.Click
cartlist1.UpdateQty()
Dim ShipMethodID As Integer
Dim objCInfo As NB_Store_CartInfo = CurrentCart.GetCurrentCart(PortalId)
objCInfo.VATNumber = txtVATCode.Text
objCInfo.PromoCode = txtPromoCode.Text
objCInfo.CountryCode = ddlCountry.SelectedValue
If rblShipMethod.SelectedIndex >= 0 Then
ShipMethodID = rblShipMethod.SelectedValue
Else
ShipMethodID = GetDefaultShipMethod(PortalId)
End If
objCInfo.ShipMethodID = ShipMethodID
CurrentCart.Save(objCInfo)
If CType(Settings("chkSmoothLogin"), Boolean) And UserId = -1 Then
Dim rTabID As Integer = CType(Settings("ddlSmoothLoginTab"), Integer)
Dim rtnUrl As String = "?ReturnURL=/tabid/" & TabId & "/stg/2/Default.aspx"
If rTabID = TabId Then
Response.Redirect(NavigateURL(rTabID, "", "ctl=login", "stg=2") & rtnUrl)
Else
Response.Redirect(NavigateURL(rTabID, "") & rtnUrl)
End If
Else
Response.Redirect(NavigateURL(TabId, "", "stg=2"))
End If
End Sub
Private Sub cartlist1_CartIsEmpty() Handles cartlist1.CartIsEmpty
Response.Redirect(NavigateURL(TabId))
End Sub
Private Sub cartlist1_RecalculateCart() Handles cartlist1.RecalculateCart, cmdPromo.Click, cmdVAT.Click
If txtPromoCode.Visible Or txtVATCode.Visible Then
'save promocode to cart
Dim objCartInfo As NB_Store_CartInfo
objCartInfo = CurrentCart.GetCurrentCart(PortalId)
objCartInfo.PromoCode = txtPromoCode.Text
objCartInfo.VATNumber = txtVATCode.Text
CurrentCart.Save(objCartInfo)
cartlist1.PopulateCartList()
End If
populateShipMethod()
End Sub
Private Sub cartlist1_ValidateCart() Handles cartlist1.ValidateCart
CurrentCart.ValidateCart(PortalId, UserInfo)
End Sub
Private Sub ReDisplayCart()
Dim objCInfo As NB_Store_CartInfo = CurrentCart.GetCurrentCart(PortalId)
Dim ShipMethodID As Integer
cmdOrder.Visible = True
If Stage = "1" Then
objCInfo.VATNumber = txtVATCode.Text
objCInfo.PromoCode = txtPromoCode.Text
objCInfo.CountryCode = ddlCountry.SelectedValue
If rblShipMethod.SelectedIndex >= 0 Then
ShipMethodID = rblShipMethod.SelectedValue
Else
ShipMethodID = GetDefaultShipMethod(PortalId)
End If
End If
If Stage = "3" Then
If rblShipMethod2.SelectedIndex >= 0 Then
ShipMethodID = rblShipMethod2.SelectedValue
Else
ShipMethodID = GetDefaultShipMethod(PortalId)
End If
End If
objCInfo.ShipMethodID = ShipMethodID
CurrentCart.Save(objCInfo)
If Stage = "1" Then
SetUpCartList()
cartlist1.PopulateCartList()
End If
If Stage = "3" Then
SetUpOrderList()
cartlist2.PopulateCartList()
End If
populateShipMethod()
End Sub
Private Sub cmdContShop_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdContShop.Click
If IsNumeric(CType(Settings("lstTabContShop"), String)) Then
Response.Redirect(NavigateURL(CType(Settings("lstTabContShop"), Integer)))
Else
Response.Redirect(NavigateURL())
End If
End Sub
#End Region
#Region "Cart View Methods"
Private Sub HideCartOptions()
If CType(Settings("chkHideVAT"), Boolean) Then
txtVATCode.Visible = False
txtVATCode2.Visible = False
cmdVAT.Visible = False
plVATCode.Visible = False
plVATCode2.Visible = False
divVATCode.Visible = False
End If
If CType(Settings("chkHidePromo"), Boolean) Then
txtPromoCode.Visible = False
cmdPromo.Visible = False
plPromoCode.Visible = False
divPromoCode.Visible = False
End If
If CType(Settings("chkHideCountry"), Boolean) Then
ddlCountry.Visible = False
plShipCountry1.Visible = False
divShipCountry.Visible = False
End If
If Not CType(Settings("chkShowShipMethod"), Boolean) Then
rblShipMethod.Visible = False
divShipMethod.Visible = False
divShipMethod2.Visible = False
End If
Select Case CType(Settings("rblGatewayDisplay"), String)
Case "1"
pnlGateway1.Visible = True
pnlGateway2.Visible = False
Case "2"
pnlGateway1.Visible = False
pnlGateway2.Visible = True
Case "3"
pnlGateway1.Visible = True
pnlGateway2.Visible = True
Case Else
pnlGateway1.Visible = True
pnlGateway2.Visible = False
End Select
End Sub
Private Sub SetUpCartList()
Dim objTaxCalc As New TaxCalcController(PortalId)
Dim objCInfo As NB_Store_CartInfo
objCInfo = CurrentCart.GetCurrentCart(PortalId)
Dim ShipMethodID As Integer = objCInfo.ShipMethodID
objCInfo.ShipType = ""
CurrentCart.Save(objCInfo)
If ShipMethodID <= 0 Then
ShipMethodID = GetDefaultShipMethod(PortalId)
End If
pnlCart.Visible = True
If Not Page.IsPostBack Then populateShipMethod()
cartlist1.CartID = objCInfo.CartID
cartlist1.PortalID = PortalId
cartlist1.ShipMethodID = ShipMethodID
cartlist1.TaxOption = objTaxCalc.getTaxOption
cartlist1.ResourceFile = LocalResourceFile
cartlist1.ShowDiscountCol = CBool(Settings("chkShowDiscountCol"))
cartlist1.NoUpdates = False
End Sub
Private Sub DisplayEmptyCart()
Dim objSCtrl As New NB_Store.SettingsController
Dim objInfo As NB_Store_SettingsTextInfo
Dim EmptyCartText As String = Localization.GetString("EmptyCart", LocalResourceFile)
pnlEmptyCart.Visible = True
objInfo = objSCtrl.GetSettingsText(PortalId, "emptycart.text", GetCurrentCulture)
If Not objInfo Is Nothing Then
If objInfo.SettingText <> "" Then
EmptyCartText = System.Web.HttpUtility.HtmlDecode(objInfo.SettingText)
'get order details and change tokens
Dim objTR As New TokenStoreReplace(PortalId, GetCurrentCulture)
EmptyCartText = objTR.DoTokenReplace(EmptyCartText)
End If
End If
phEmptyCart.Controls.Add(New LiteralControl(EmptyCartText))
End Sub
Private Sub DisplayMinimumCart()
Dim objSCtrl As New NB_Store.SettingsController
Dim objInfo As NB_Store_SettingsTextInfo
Dim objVInfo As NB_Store_SettingsInfo
Dim EmptyCartText As String = Localization.GetString("EmptyCart", LocalResourceFile)
pnlEmptyCart.Visible = True
objInfo = objSCtrl.GetSettingsText(PortalId, "minimumcarttotal.text", GetCurrentCulture)
If Not objInfo Is Nothing Then
If objInfo.SettingText <> "" Then
EmptyCartText = System.Web.HttpUtility.HtmlDecode(objInfo.SettingText)
End If
End If
Dim MinimumTotal As Double = -1
objVInfo = objSCtrl.GetSetting(PortalId, "minimumcarttotal.limit", GetCurrentCulture)
If Not objVInfo Is Nothing Then
EmptyCartText = Replace(EmptyCartText, "[TAG:CARTMINIMUM]", objVInfo.SettingValue)
End If
EmptyCartText = Replace(EmptyCartText, "[TAG:CARTTOTAL]", FormatToStoreCurrency(PortalId, CurrentCart.GetCartItemTotal(PortalId)))
phEmptyCart.Controls.Add(New LiteralControl(EmptyCartText))
End Sub
Private Sub populateShipMethod()
If rblShipMethod.Visible Or rblShipMethod2.Visible Then
Dim objCtrl As New ShipController
Dim objSCtrl As New SettingsController
Dim objSTInfo As NB_Store_SettingsTextInfo
Dim objInfo As NB_Store_ShippingMethodInfo
Dim aryList As ArrayList
Dim li As ListItem
Dim strText As String = ""
Dim ShipCost As Decimal
Dim objCInfo As NB_Store_CartInfo = CurrentCart.GetCurrentCart(PortalId)
Dim ShipMethodID As Integer
ShipMethodID = objCInfo.ShipMethodID
aryList = objCtrl.GetShippingMethodEnabledList(PortalId)
rblShipMethod.Items.Clear()
rblShipMethod2.Items.Clear()
For Each objInfo In aryList
Dim cartTot As CartTotals
cartTot = CurrentCart.GetCalulatedTotals(PortalId, objCInfo.VATNumber, objCInfo.CountryCode, objCInfo.ShipType, objInfo.ShipMethodID)
ShipCost = cartTot.ShipAmt
li = New ListItem
li.Value = objInfo.ShipMethodID
If objInfo.TemplateName = "NONE" Then
li.Text = objInfo.MethodDesc
Else
objSTInfo = objSCtrl.GetSettingsText(PortalId, objInfo.TemplateName, GetCurrentCulture)
If objSTInfo Is Nothing Then
li.Text = objInfo.MethodDesc
Else
strText = Replace(System.Web.HttpUtility.HtmlDecode(objSTInfo.SettingText), "[TAG:SHIPPINGCOST]", FormatToStoreCurrency(PortalId, ShipCost))
li.Text = strText
End If
End If
If objInfo.ShipMethodID = ShipMethodID Then
li.Selected = True
End If
'check if we need to hide for dealer or non-dealer
Dim hideShipMethod As Boolean
hideShipMethod = False
If IsDealer(PortalId, UserInfo, GetCurrentCulture) Then
If objInfo.Dealer = False Then hideShipMethod = True
End If
If Not IsDealer(PortalId, UserInfo, GetCurrentCulture) Then
If objInfo.NonDealer = False Then hideShipMethod = True
End If
If ShipCost >= 0 And Not (hideShipMethod) Then
rblShipMethod.Items.Add(li)
rblShipMethod2.Items.Add(li)
End If
Next
'check shipping method select is still visible, if not reset to first method in list
If rblShipMethod.Items.FindByValue(ShipMethodID) Is Nothing Then
If rblShipMethod.Items.Count > 0 Then
ShipMethodID = rblShipMethod.Items(0).Value
rblShipMethod.Items(0).Selected = True
rblShipMethod2.Items(0).Selected = True
ReDisplayCart()
Else
'unable to calcualte a cost for shipping so display special shipping needed message.
DisplaySpecialShippingMsg()
End If
End If
Else
'multiple shipping turned off, but check for valid shipping.
Dim cartTot As CartTotals
Dim objCInfo As NB_Store_CartInfo = CurrentCart.GetCurrentCart(PortalId)
Dim ShipMethodID As Integer
ShipMethodID = GetDefaultShipMethod(PortalId)
cartTot = CurrentCart.GetCalulatedTotals(PortalId, objCInfo.VATNumber, objCInfo.CountryCode, objCInfo.ShipType, ShipMethodID)
If cartTot.ShipAmt < 0 Then
'unable to calcualte a cost for shipping so display special shipping needed message.
DisplaySpecialShippingMsg()
End If
End If
End Sub
Private Sub DisplaySpecialShippingMsg()
'unable to calcualte a cost for shipping so display special shipping needed message.
pnlPayRtn.Visible = True
cmdOrder.Visible = False
cartlist1.ShippingHidden = True
cartlist1.PopulateCartList()
DisplayMsgText(PortalId, plhPayRtn, "specialshipping.text", "Special Shipping Required")
End Sub
#End Region
#End Region
#Region "Address"
#Region "Address Events"
Private Sub radShipping_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radShipping.CheckedChanged
If radShipping.Checked Then
saveAddrCookie()
CurrentCart.SaveShipType(PortalId, "SHIP")
populateAddress()
Response.Redirect(NavigateURL(TabId, "", "stg=2"))
End If
End Sub
Private Sub radNone_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radNone.CheckedChanged
If radNone.Checked Then
saveAddrCookie()
CurrentCart.SaveShipType(PortalId, "NONE")
populateAddress()
Response.Redirect(NavigateURL(TabId, "", "stg=2"))
End If
End Sub
Private Sub radBilling_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles radBilling.CheckedChanged
If radBilling.Checked Then
saveAddrCookie()
CurrentCart.SaveShipType(PortalId, "BILL")
populateAddress()
Response.Redirect(NavigateURL(TabId, "", "stg=2"))
End If
End Sub
Private Sub cmdNext1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdNext1.Click
'address has been entered, so Save order
If Page.IsValid Then
If chkSaveAddrCookie.Checked Then
saveAddrCookie()
Else
removeAddrCookie()
End If
SaveOrder()
Response.Redirect(NavigateURL(TabId, "", "stg=3"))
End If
End Sub
Private Sub cmdBack1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdBack1.Click
Response.Redirect(NavigateURL(TabId, "", "stg=1"))
End Sub
Private Sub cmdBack2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdBack2.Click
Response.Redirect(NavigateURL(TabId, "", "stg=2"))
End Sub
Private Sub cmdCancelOrder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCancelOrder.Click
CurrentCart.CancelOrder(PortalId)
If IsNumeric(CType(Settings("lstTabs"), String)) Then
Response.Redirect(NavigateURL(CType(Settings("lstTabs"), Integer)))
Else
Response.Redirect(NavigateURL())
End If
End Sub
#End Region
#Region "Address Methods"
Private Function AllowNonUserOrder() As Boolean
Return CType(Settings("chkNonUserOrder"), Boolean)
End Function
Private Function IsNonUserOrder() As Boolean
If UserId >= 0 Then
Return False
Else
Return True
End If
End Function
Private Sub populateAddress()
Dim objCtrl As New OrderController
Dim objInfo As NB_Store_OrdersInfo
Dim objCInfo As NB_Store_CartInfo = CurrentCart.GetCurrentCart(PortalId)
Dim objAInfo As NB_Store_AddressInfo
pnlAddressDetails.Visible = True
valEmail.ErrorMessage = Localization.GetString("valEmail", LocalResourceFile)
revEmail.ErrorMessage = Localization.GetString("revEmail", LocalResourceFile)
'disable address validate
If CType(Settings("chkMinimumValidate"), Boolean) Then
billaddress.NoValidate = True
shipaddress.NoValidate = True
Else
billaddress.NoValidate = False
shipaddress.NoValidate = False
End If
'hide no shipping radio
If CType(Settings("chkHideShip"), Boolean) Then
radNone.Visible = False
lblNone.Visible = False
End If
'hide set default email and address options if generic user
If IsNonUserOrder() Then
chkDefaultAddress.Visible = False
chkDefaultEmail.Visible = False
plDefaultAddress.Visible = False
plDefaultEmail.Visible = False
End If
'set display of radio shipping type (from currentcart)
pnlShipAddress.Visible = False
Select Case objCInfo.ShipType
Case "NONE"
radNone.Checked = True
Case "BILL"
radBilling.Checked = True
Case "SHIP"
radShipping.Checked = True
pnlShipAddress.Visible = True
Case Else
radBilling.Checked = True
objCInfo.ShipType = "BILL"
CurrentCart.Save(objCInfo)
End Select
objInfo = objCtrl.GetOrder(CurrentCart.GetCurrentCart(PortalId).OrderID)
'initialize the address controls so that the templates get displayed.
billaddress.AddressDataInfo = New NB_Store_AddressInfo
shipaddress.AddressDataInfo = New NB_Store_AddressInfo
If objInfo Is Nothing Then
If getStoreCookieValue(PortalId, CurrentCart.getCartID(PortalId), "BAddressName") <> "" Then
'get address cookie
Dim AddrCookie As HttpCookie = getStoreCookie(PortalId, CurrentCart.getCartID(PortalId))
txtEmail.Text = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "Email").ToString)
billaddress.CountryCode = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BCountryCode").ToString)
shipaddress.CountryCode = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SCountryCode").ToString)
objAInfo = New NB_Store_AddressInfo
objAInfo.AddressDescription = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BAddressDescription").ToString)
objAInfo.AddressName = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BAddressName").ToString)
objAInfo.AddressName2 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BAddressName2").ToString)
objAInfo.Address1 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BAddress1").ToString)
objAInfo.Address2 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BAddress2").ToString)
objAInfo.City = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BCity").ToString)
objAInfo.CountryCode = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BCountryCode").ToString)
objAInfo.RegionCode = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BRegion").ToString)
objAInfo.Phone1 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BPhone1").ToString)
objAInfo.Phone2 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BPhone2").ToString)
objAInfo.PostalCode = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BPostalCode").ToString)
objAInfo.CompanyName = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BCompanyName").ToString)
objAInfo.Extra1 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BExtra1").ToString)
objAInfo.Extra2 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BExtra2").ToString)
objAInfo.Extra3 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BExtra3").ToString)
objAInfo.Extra4 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "BExtra4").ToString)
billaddress.AddressDataInfo = objAInfo
objAInfo = New NB_Store_AddressInfo
objAInfo.AddressDescription = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SAddressDescription").ToString)
objAInfo.AddressName = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SAddressName").ToString)
objAInfo.AddressName2 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SAddressName2").ToString)
objAInfo.Address1 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SAddress1").ToString)
objAInfo.Address2 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SAddress2").ToString)
objAInfo.City = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SCity").ToString)
objAInfo.CountryCode = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SCountryCode").ToString)
objAInfo.RegionCode = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SRegion").ToString)
objAInfo.Phone1 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SPhone1").ToString)
objAInfo.Phone2 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SPhone2").ToString)
objAInfo.PostalCode = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SPostalCode").ToString)
objAInfo.CompanyName = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SCompanyName").ToString)
objAInfo.Extra1 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SExtra1").ToString)
objAInfo.Extra2 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SExtra2").ToString)
objAInfo.Extra3 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SExtra3").ToString)
objAInfo.Extra4 = Server.UrlDecode(getStoreCookieValue(PortalId, AddrCookie, "SExtra4").ToString)
shipaddress.AddressDataInfo = objAInfo
Else
shipaddress.CountryCode = objCInfo.CountryCode
objAInfo = New NB_Store_AddressInfo
If IsNonUserOrder() Then
objAInfo.AddressName = ""
txtEmail.Text = ""
Else
objAInfo.AddressName = UserInfo.FirstName
objAInfo.AddressName2 = UserInfo.LastName
txtEmail.Text = UserInfo.Email
End If
objAInfo.Address1 = UserInfo.Profile.Unit
objAInfo.Address2 = UserInfo.Profile.Street
objAInfo.City = UserInfo.Profile.City
Dim c As String = GetCountryCodeByName(UserInfo.Profile.Country)
If c = "" Then
objAInfo.CountryCode = objCInfo.CountryCode
Else
objAInfo.CountryCode = c
End If
objAInfo.RegionCode = UserInfo.Profile.Region
objAInfo.Phone1 = UserInfo.Profile.Telephone
objAInfo.Phone2 = UserInfo.Profile.Cell
objAInfo.PostalCode = UserInfo.Profile.PostalCode
If Not IsNothing(UserInfo.Profile.GetPropertyValue("CompanyName")) Then
objAInfo.CompanyName = UserInfo.Profile.GetPropertyValue("CompanyName")
End If
billaddress.AddressDataInfo = objAInfo
End If
Else
If objInfo.Email <> "" Then
txtEmail.Text = objInfo.Email
Else
If IsNonUserOrder() Then
txtEmail.Text = ""
Else
txtEmail.Text = UserInfo.Email
End If
End If
objAInfo = objCtrl.GetOrderAddress(objInfo.BillingAddressID)
If Not objAInfo Is Nothing Then
billaddress.AddressDataInfo = objAInfo
End If
'get shipping address, if different from billing address
If objInfo.ShippingAddressID = -1 Then
radNone.Checked = True
Else
If objInfo.BillingAddressID <> objInfo.ShippingAddressID Then
objAInfo = objCtrl.GetOrderAddress(objInfo.ShippingAddressID)
If Not objAInfo Is Nothing Then
shipaddress.AddressDataInfo = objAInfo
End If
End If
End If
End If
End Sub
Private Sub DisplayExtraDetailMsg()
DisplayMsgText(PortalId, plhNoteMsg, "extradetail.text", Localization.GetString("ExtraDetail", LocalResourceFile))
End Sub
Private Sub DisplayLoginMsg()
pnlLogin.Visible = True
DisplayMsgText(PortalId, phLogin, "logintext.text", Localization.GetString("LoginText", LocalResourceFile))
End Sub
Private Function DisplayLogin() As Boolean
If UserId >= 0 Or IsNumeric(Request.QueryString("logmsg")) Then
Return False
End If
If AllowNonUserOrder() Then
If CType(Settings("chkDisableLoginMsg"), Boolean) Then
Return False
End If
End If
Return True
End Function
Private Sub SaveOrder()
Dim objOCtrl As New OrderController
Dim objInfo As NB_Store_OrdersInfo
Dim CountryCode As String = "XX"
Dim BillID As Integer
Dim ShipID As Integer
Dim objCInfo As NB_Store_CartInfo = CurrentCart.GetCurrentCart(PortalId)
Dim VATNumberAddr As String = ""
'update currentcart with selected shipping country & Shipping type
If radNone.Checked Then
objCInfo.ShipType = "NONE"
objCInfo.CountryCode = billaddress.AddressDataInfo.CountryCode
End If
If radBilling.Checked Then
objCInfo.ShipType = "BILL"
objCInfo.CountryCode = billaddress.AddressDataInfo.CountryCode
End If
If radShipping.Checked Then
objCInfo.ShipType = "SHIP"
objCInfo.CountryCode = shipaddress.AddressDataInfo.CountryCode
End If
objCInfo.VATNumber = txtVATCode2.Text
CurrentCart.Save(objCInfo)
'Does email enterd need to be save onto order or updated to account?
Dim OrderEmail As String = UpdateOrderEmail(txtEmail.Text, billaddress)
'create the order from the currentcart info
objInfo = CurrentCart.CreateOrder(UserId, PortalId, txtNoteMsg.Text, OrderEmail, UserInfo)
'and form xml data
objInfo.Stg2FormXML = Stg2Form.XMLData
'update address info
BillID = SaveAddress(billaddress, objInfo.OrderID)
If radNone.Checked Then ShipID = -1
If radBilling.Checked Then ShipID = BillID
If radShipping.Checked Then ShipID = SaveAddress(shipaddress, objInfo.OrderID)
'update new order with address id's
objInfo.BillingAddressID = BillID
objInfo.ShippingAddressID = ShipID
objOCtrl.UpdateObjOrder(objInfo)
End Sub
Private Function UpdateOrderEmail(ByVal OrderEmail As String, ByVal AddCtrl As NB_Store.Address) As String
Dim rtnEmail As String = ""
If IsNonUserOrder() Then
Return OrderEmail
Else
Dim blnUpdate As Boolean = False
If UserInfo.Email <> OrderEmail Then
rtnEmail = OrderEmail
If chkDefaultEmail.Checked Then
UserInfo.Email = OrderEmail
UserInfo.Membership.Email = OrderEmail
rtnEmail = ""
blnUpdate = True
End If
End If
If chkDefaultAddress.Checked Then
Dim objAInfo As New NB_Store_AddressInfo
objAInfo = AddCtrl.AddressDataInfo
UserInfo.Profile.Unit = objAInfo.Address1
UserInfo.Profile.Street = objAInfo.Address2
UserInfo.Profile.Region = objAInfo.RegionCode
UserInfo.Profile.PostalCode = objAInfo.PostalCode
UserInfo.Profile.City = objAInfo.City
'remove this, the DNN country uses country name, and it's not always compatible.
'UserInfo.Profile.Country = GetCountryByCode(objAInfo.CountryCode)
UserInfo.Profile.Telephone = objAInfo.Phone1
UserInfo.Profile.Cell = objAInfo.Phone2
If Not IsNothing(UserInfo.Profile.GetPropertyValue("CompanyName")) Then
UserInfo.Profile.SetProfileProperty("CompanyName", objAInfo.CompanyName)
End If
blnUpdate = True
End If
If blnUpdate Then
Users.UserController.UpdateUser(PortalId, UserInfo)
End If
End If
Return rtnEmail
End Function
Private Function SaveAddress(ByVal AddCtrl As NB_Store.Address, ByVal OrderID As Integer) As Integer
'create new address for all
Dim objOCtrl As New OrderController
Dim objAInfo As New NB_Store_AddressInfo
objAInfo = AddCtrl.AddressDataInfo
objAInfo.PortalID = PortalId
objAInfo.CreatedByUser = UserId
objAInfo.CreatedDate = Now
objAInfo.OrderID = OrderID
objAInfo.PrimaryAddress = False
objAInfo.AddressID = -1
objAInfo.UserID = UserId
objAInfo = objOCtrl.UpdateObjOrderAddress(objAInfo)
Return objAInfo.AddressID
End Function
Private Sub saveAddrCookie()
Dim FullCookieName As String = STOREPREFIX & CurrentCart.getCartID(PortalId) & "_Portal" & PortalId.ToString
Dim AddrCookie As New HttpCookie(FullCookieName)
Dim objAInfo As NB_Store_AddressInfo
objAInfo = billaddress.AddressDataInfo()
AddrCookie("Email") = StoreEncrypt(PortalId, Server.UrlEncode(txtEmail.Text))
AddrCookie("BAddressDescription") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.AddressDescription))
AddrCookie("BAddressName") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.AddressName))
AddrCookie("BAddressName2") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.AddressName2))
AddrCookie("BAddress1") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Address1))
AddrCookie("BAddress2") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Address2))
AddrCookie("BCity") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.City))
AddrCookie("BCountryCode") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.CountryCode))
AddrCookie("BRegion") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.RegionCode))
AddrCookie("BPhone1") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Phone1))
AddrCookie("BPhone2") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Phone2))
AddrCookie("BPostalCode") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.PostalCode))
AddrCookie("BCompanyName") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.CompanyName))
AddrCookie("BExtra1") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Extra1))
AddrCookie("BExtra2") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Extra2))
AddrCookie("BExtra3") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Extra3))
AddrCookie("BExtra4") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Extra4))
objAInfo = shipaddress.AddressDataInfo()
AddrCookie("SAddressDescription") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.AddressDescription))
AddrCookie("SAddressName") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.AddressName))
AddrCookie("SAddressName2") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.AddressName2))
AddrCookie("SAddress1") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Address1))
AddrCookie("SAddress2") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Address2))
AddrCookie("SCity") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.City))
AddrCookie("SCountryCode") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.CountryCode))
AddrCookie("SRegion") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.RegionCode))
AddrCookie("SPhone1") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Phone1))
AddrCookie("SPhone2") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Phone2))
AddrCookie("SPostalCode") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.PostalCode))
AddrCookie("SCompanyName") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.CompanyName))
AddrCookie("SExtra1") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Extra1))
AddrCookie("SExtra2") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Extra2))
AddrCookie("SExtra3") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Extra3))
AddrCookie("SExtra4") = StoreEncrypt(PortalId, Server.UrlEncode(objAInfo.Extra4))
AddrCookie.Expires = DateAdd(DateInterval.Day, 30, Today)
HttpContext.Current.Response.Cookies.Add(AddrCookie)
End Sub
Private Sub removeAddrCookie()
Dim FullCookieName As String = STOREPREFIX & CurrentCart.getCartID(PortalId) & "_Portal" & PortalId.ToString
Dim AddrCookie As New HttpCookie(FullCookieName)
AddrCookie("Email") = ""