1 <?php
2
3 4 5 6 7 8 9
10 class CheckoutStep_Membership extends CheckoutStep{
11
12 static $allowed_actions = array('membership', 'LoginForm');
13 static $skip_if_logged_in = true;
14
15 function StepIsActive() {
16 $conf = SiteConfig::current_site_config();
17
18 if (!$conf->CartRegistraionAvailable()) {
19 return false;
20 }
21
22 if (self::$skip_if_logged_in && Member::currentUser()) {
23 return false;
24 }
25 return true;
26 }
27
28 29 30
31 function membership() {
32 $conf = SiteConfig::current_site_config();
33
34
35 if (!$conf->CartRegistraionAvailable()) {
36 Director::redirect($this->NextStepLink());
37 return;
38 }
39
40
41 if (self::$skip_if_logged_in && Member::currentUser()) {
42 Director::redirect($this->NextStepLink());
43 return;
44 }
45
46 Session::set('BackURL', $this->owner->Link());
47 $rs = array(
48 'Title' => $this->stepTitle(),
49 'Content' => $this->stepMessage(),
50 'Form' => $this->LoginForm(),
51 );
52 if (Member::currentUser() || !$conf->CartRegisterRequire) {
53 $rs['NextLink'] = $this->NextStepLink();
54 }
55 if ($conf->CartRegisterEnabled) {
56 $rs['RegistrationLink'] = RegistrationPage::find_link();
57 }
58 return $rs;
59
60 }
61
62 63 64 65 66 67 68
69 function LoginForm(){
70 $conf = SiteConfig::current_site_config();
71 $form = new MemberLoginForm($this->owner, 'LoginForm');
72 if (Member::currentUser()) {
73 $form->actions()->push(new FormAction("docontinue", _t('CheckoutPage.NextButton', "Continue")));
74 }
75 else {
76 77 78 79 80 81 82 83
84 }
85
86 $this->owner->extend('updateLoginForm', $form);
87 return $form;
88 }
89
90 function docontinue(){
91 $this->owner->redirect($this->NextStepLink());
92 }
93
94 function createaccount($requestdata){
95
96 if (Member::currentUser()) {
97 Director::redirect($this->NextStepLink());
98 return;
99 }
100
101 Session::set('BackURL', $this->owner->Link());
102 Director::redirect(RegistrationPage::find_link());
103 }
104 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-