OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxcountry.php
Go to the documentation of this file.
1 <?php
2 
3 
8 class oxCountry extends oxI18n
9 {
15  protected $_sClassName = 'oxcountry';
16 
22  protected $_aStates = null;
23 
27  public function __construct()
28  {
30  $this->init( 'oxcountry' );
31  }
32 
38  public function isForeignCountry()
39  {
40  return !in_array($this->getId(), $this->getConfig()->getConfigParam( 'aHomeCountry' ));
41  }
42 
48  public function isInEU()
49  {
50  return (bool) ($this->oxcountry__oxvatstatus->value == 1);
51  }
52 
58  public function getStates()
59  {
60  if (!is_null($this->_aStates))
61  return $this->_aStates;
62 
63  $sCountryId = $this->getId();
64  $sViewName = getViewName( "oxstates", $this->getLanguage() );
65  $sQ = "select * from {$sViewName} where `oxcountryid` = '$sCountryId' order by `oxtitle` ";
66  $this->_aStates = oxNew("oxlist");
67  $this->_aStates->init("oxstate");
68  $this->_aStates->selectString($sQ);
69 
70  return $this->_aStates;
71  }
72 
80  public function getIdByCode( $sCode )
81  {
82  $oDb = oxDb::getDb();
83  return $oDb->getOne( "select oxid from oxcountry where oxisoalpha2 = " . $oDb->quote( $sCode ) );
84  }
85 
92  {
93  return $this->oxcountry__oxisoalpha2->value == 'GR' ? 'EL' : $this->oxcountry__oxisoalpha2->value;
94  }
95 
96 }