OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
oxaddress.php
Go to the documentation of this file.
1 <?php
2 
7 class oxAddress extends oxBase
8 {
14  protected $_sClassName = 'oxaddress';
15 
21  protected $_blSelected = false;
22 
28  public function __construct()
29  {
31  $this->init( 'oxaddress' );
32  }
33 
39  public function __toString()
40  {
41  return $this->toString();
42  }
43 
49  public function toString()
50  {
51  $sFirstName = $this->oxaddress__oxfname->value;
52  $sLastName = $this->oxaddress__oxlname->value;
53  $sStreet = $this->oxaddress__oxstreet->value;
54  $sStreetNr = $this->oxaddress__oxstreetnr->value;
55  $sCity = $this->oxaddress__oxcity->value;
56 
57  //format it
58  $sAddress = "";
59  if ($sFirstName || $sLastName) {
60  $sAddress = $sFirstName. ($sFirstName?" ":"") . "$sLastName, ";
61  }
62  $sAddress .= "$sStreet $sStreetNr $sCity";
63 
64  $sAddress = trim($sAddress);
65 
66  return $sAddress;
67  }
68 
74  public function getEncodedDeliveryAddress()
75  {
76  return md5($this->_getMergedAddressFields());
77  }
78 
84  public function getState()
85  {
86  return $this->oxaddress__oxstateid->value;
87  }
88 
94  public function isSelected()
95  {
96  return $this->_blSelected;
97  }
98 
104  public function setSelected()
105  {
106  $this->_blSelected = true;
107  }
108 
114  protected function _getMergedAddressFields()
115  {
116  $sDelAddress = '';
117  $sDelAddress .= $this->oxaddress__oxcompany;
118  $sDelAddress .= $this->oxaddress__oxfname;
119  $sDelAddress .= $this->oxaddress__oxlname;
120  $sDelAddress .= $this->oxaddress__oxstreet;
121  $sDelAddress .= $this->oxaddress__oxstreetnr;
122  $sDelAddress .= $this->oxaddress__oxaddinfo;
123  $sDelAddress .= $this->oxaddress__oxcity;
124  $sDelAddress .= $this->oxaddress__oxcountryid;
125  $sDelAddress .= $this->oxaddress__oxstateid;
126  $sDelAddress .= $this->oxaddress__oxzip;
127  $sDelAddress .= $this->oxaddress__oxfon;
128  $sDelAddress .= $this->oxaddress__oxfax;
129  $sDelAddress .= $this->oxaddress__oxsal;
130 
131  return $sDelAddress;
132  }
133 }