1 <?php
2
3 4 5 6 7 8 9 10 11
12 class CheckoutStep_ContactDetails extends CheckoutStep {
13
14 static $allowed_actions = array('contactdetails', 'ContactDetailsForm');
15
16 17 18
19 function contactdetails() {
20 if (SiteConfig::current_site_config()->CartRegisterRequire && !Member::currentUser()) {
21 return Director::redirect('/Security/login?BackURL=' . $this->owner->Link());
22 }
23 $form = $this->ContactDetailsForm();
24
25
26 if ($form->MessageType() != 'required') {
27
28 if($member = Member::currentUser()){
29 $form->loadDataFrom($member);
30 }
31
32 $form->loadDataFrom(Cart::get_info());
33 }
34 return array(
35 'Title' => $this->stepTitle(),
36 'Content' => $this->stepMessage(),
37 'Form' => $form
38 );
39 }
40
41 42 43 44 45 46 47 48 49 50 51 52 53
54 function ContactDetailsForm() {
55 $form = new Form(
56 $this->owner,
57 'ContactDetailsForm',
58 $this->owner->getContactDetailsFields(),
59 $this->getStepActions(new FormAction("setcontactdetails", _t('OrderForm.SaveContactsButton', "Continue"))),
60 new RequiredFields($this->owner->getOrderRequired())
61 );
62 $this->owner->extend('updateContactDetailsForm', $form);
63 return $form;
64 }
65
66 67 68 69 70 71 72 73 74 75 76 77 78 79
80 function setcontactdetails($data, $form) {
81 $this->owner->extend('onBeforeSetContactDetails', $data, $form);
82 foreach ($form->fields()->saveableFields() as $field) {
83 if ($field->name == 'SecurityID') continue;
84 Cart::set_info($field->name, $data[$field->name]);
85 }
86 $this->owner->extend('onAfterSetContactDetails', $data, $form);
87 Director::redirect($this->NextStepLink());
88 }
89
90 }
[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.
-