Ejemplo n.º 1
0
 /**
  * Get field value
  *
  * @param string  $fieldName    Field name
  * @param boolean $processValue Process value flag OPTIONAL
  *
  * @return string
  */
 public function getFieldValue($fieldName, $processValue = false)
 {
     $result = '';
     $address = $this->getAddressInfo();
     if ($this->getCart() && $this->getCart()->getProfile() && 'email' == $fieldName) {
         $result = $this->getCart()->getProfile()->getLogin();
     } elseif ($this->getCart() && $this->getCart()->getProfile() && 'password' == $fieldName) {
         $result = \XLite\Core\Session::getInstance()->createProfilePassword;
     } elseif (isset($address)) {
         $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($fieldName);
         // $methodName assembled from 'get' + camelized $fieldName
         $result = $address->{$methodName}();
         if ($result && false !== $processValue) {
             switch ($fieldName) {
                 case 'state_id':
                     $result = $address->getCountry()->hasStates() ? $address->getState()->getState() : null;
                     break;
                 case 'custom_state':
                     $result = $address->getCountry()->hasStates() ? null : $result;
                     break;
                 case 'country_code':
                     $result = $address->getCountry()->getCountry();
                     break;
                 case 'type':
                     $result = $address->getTypeName();
                     break;
                 default:
             }
         }
     } elseif (in_array($fieldName, array('country_code', 'state_id', 'custom_state', 'zipcode'))) {
         $result = \XLite\Model\Address::getDefaultFieldPlainValue($fieldName);
     }
     return $result;
 }