/**
  * @param Member $member
  * @return FieldList
  **/
 public function getFields(Member $member = null)
 {
     $fields = parent::getEcommerceFields();
     $fields->push(new HeaderField('BillingDetails', _t('OrderAddress.BILLINGDETAILS', 'Billing Address'), 3));
     $fields->push(new TextField('Phone', _t('OrderAddress.PHONE', 'Phone')));
     $billingFields = new CompositeField();
     $hasPreviousAddresses = false;
     if ($member) {
         if ($member->exists() && !$member->IsShopAdmin()) {
             $this->FillWithLastAddressFromMember($member, true);
             $addresses = $member->previousOrderAddresses($this->baseClassLinkingToOrder(), $this->ID, $onlyLastRecord = false, $keepDoubles = false);
             //we want MORE than one here not just one.
             if ($addresses->count() > 1) {
                 $fields->push(SelectOrderAddressField::create('SelectBillingAddressField', _t('OrderAddress.SELECTBILLINGADDRESS', 'Select Billing Address'), $addresses));
                 $hasPreviousAddresses = true;
             }
         }
     }
     //$billingFields->push(new TextField('MobilePhone', _t('OrderAddress.MOBILEPHONE','Mobile Phone')));
     $mappingArray = $this->Config()->get("fields_to_google_geocode_conversion");
     if (is_array($mappingArray) && count($mappingArray)) {
         if (!class_exists("GoogleAddressField")) {
             user_error("You must install the Sunny Side Up google_address_field module OR remove entries from: BillingAddress.fields_to_google_geocode_conversion");
         }
         $billingFields->push($billingEcommerceGeocodingField = new GoogleAddressField('BillingEcommerceGeocodingField', _t('OrderAddress.FIND_ADDRESS', 'Find address'), Session::get("BillingEcommerceGeocodingFieldValue")));
         $billingEcommerceGeocodingField->setFieldMap($mappingArray);
         //$billingFields->push(new HiddenField('Address2', "NOT SET", "NOT SET"));
         //$billingFields->push(new HiddenField('City', "NOT SET", "NOT SET"));
     }
     //$billingFields->push(new TextField('Prefix', _t('OrderAddress.PREFIX','Title (e.g. Ms)')));
     $billingFields->push(new TextField('Address', _t('OrderAddress.ADDRESS', 'Address')));
     $billingFields->push(new TextField('Address2', _t('OrderAddress.ADDRESS2', '')));
     $billingFields->push(new TextField('City', _t('OrderAddress.CITY', 'Town')));
     $billingFields->push($this->getPostalCodeField("PostalCode"));
     $billingFields->push($this->getRegionField("RegionID", "RegionCode"));
     $billingFields->push($this->getCountryField("Country"));
     $billingFields->addExtraClass('billingFields');
     $billingFields->addExtraClass("orderAddressHolder");
     $this->makeSelectedFieldsReadOnly($billingFields->FieldList());
     $fields->push($billingFields);
     $this->extend('augmentEcommerceBillingAddressFields', $fields);
     return $fields;
 }
 /**
  * Puts together the fields for the Order Form (and other front-end purposes).
  * @param Member $member
  * @return FieldList
  **/
 public function getFields(Member $member = null)
 {
     $fields = parent::getEcommerceFields();
     $hasPreviousAddresses = false;
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         $shippingFieldsHeader = new CompositeField(new HeaderField('SendGoodsToADifferentAddress', _t('OrderAddress.SENDGOODSTODIFFERENTADDRESS', 'Send goods to different address'), 3), new LiteralField('ShippingNote', '<p class="message warning">' . _t('OrderAddress.SHIPPINGNOTE', 'Your goods will be sent to the address below.') . '</p>'));
         if ($member) {
             if ($member->exists() && !$member->IsShopAdmin()) {
                 $this->FillWithLastAddressFromMember($member, true);
                 $addresses = $member->previousOrderAddresses($this->baseClassLinkingToOrder(), $this->ID, $onlyLastRecord = false, $keepDoubles = false);
                 //we want MORE than one here not just one.
                 if ($addresses->count() > 1) {
                     $hasPreviousAddresses = true;
                     $shippingFieldsHeader->push(SelectOrderAddressField::create('SelectShippingAddressField', _t('OrderAddress.SELECTBILLINGADDRESS', 'Select Shipping Address'), $addresses));
                 }
             }
             $shippingFields = new CompositeField(new TextField('ShippingFirstName', _t('OrderAddress.FIRSTNAME', 'First Name')), new TextField('ShippingSurname', _t('OrderAddress.SURNAME', 'Surname')));
         } else {
             $shippingFields = new CompositeField(new TextField('ShippingFirstName', _t('OrderAddress.FIRSTNAME', 'First Name')), new TextField('ShippingSurname', _t('OrderAddress.SURNAME', 'Surname')));
         }
         $shippingFields->push(new TextField('ShippingPhone', _t('OrderAddress.PHONE', 'Phone')));
         //$shippingFields->push(new TextField('ShippingMobilePhone', _t('OrderAddress.MOBILEPHONE','Mobile Phone')));
         $mappingArray = $this->Config()->get("fields_to_google_geocode_conversion");
         if (is_array($mappingArray) && count($mappingArray)) {
             if (!class_exists("GoogleAddressField")) {
                 user_error("You must install the Sunny Side Up google_address_field module OR remove entries from: ShippingAddress.fields_to_google_geocode_conversion");
             }
             $shippingFields->push($shippingEcommerceGeocodingField = new GoogleAddressField('ShippingEcommerceGeocodingField', _t('OrderAddress.Find_Address', 'Find address'), Session::get("ShippingEcommerceGeocodingFieldValue")));
             $shippingEcommerceGeocodingField->setFieldMap($mappingArray);
             //$shippingFields->push(new HiddenField('ShippingAddress2'));
             //$shippingFields->push(new HiddenField('ShippingCity'));
         } else {
         }
         //$shippingFields->push(new TextField('ShippingPrefix', _t('OrderAddress.PREFIX','Title (e.g. Ms)')));
         $shippingFields->push(new TextField('ShippingAddress', _t('OrderAddress.ADDRESS', 'Address')));
         $shippingFields->push(new TextField('ShippingAddress2', _t('OrderAddress.ADDRESS2', '')));
         $shippingFields->push(new TextField('ShippingCity', _t('OrderAddress.CITY', 'Town')));
         $shippingFields->push($this->getRegionField("ShippingRegionID", "ShippingRegionCode"));
         $shippingFields->push($this->getPostalCodeField("ShippingPostalCode"));
         $shippingFields->push($this->getCountryField("ShippingCountry"));
         $this->makeSelectedFieldsReadOnly($shippingFields);
         $shippingFieldsHeader->addExtraClass("shippingFieldsHeader");
         $shippingFields->addExtraClass("orderAddressHolder");
         $fields->push($shippingFieldsHeader);
         $shippingFields->addExtraClass('shippingFields');
         $fields->push($shippingFields);
     }
     $this->extend('augmentEcommerceShippingAddressFields', $fields);
     return $fields;
 }