예제 #1
0
파일: AView.php 프로젝트: kirkbauer2/kirkxc
 /**
  * Return specific data for address entry. Helper.
  *
  * @param \XLite\Model\Address $address   Address
  * @param boolean              $showEmpty Show empty fields OPTIONAL
  *
  * @return array
  */
 protected function getAddressSectionData(\XLite\Model\Address $address, $showEmpty = false)
 {
     $result = array();
     $hasStates = $address->getCountry() ? $address->getCountry()->hasStates() : false;
     foreach (\XLite\Core\Database::getRepo('XLite\\Model\\AddressField')->findAllEnabled() as $field) {
         $method = 'get' . \Includes\Utils\Converter::convertToCamelCase($field->getViewGetterName() ?: $field->getServiceName());
         $addressFieldValue = $address->{$method}();
         $cssFieldName = $field->getCSSFieldName();
         switch ($field->getServiceName()) {
             case 'state_id':
                 $addressFieldValue = $hasStates ? $addressFieldValue : null;
                 if (null === $addressFieldValue && $hasStates) {
                     $addressFieldValue = $address->getCustomState();
                 }
                 break;
             case 'custom_state':
                 $addressFieldValue = $hasStates ? null : $address->getCustomState();
                 $cssFieldName = $hasStates ? $cssFieldName : 'address-state';
                 break;
             default:
         }
         if ($addressFieldValue || $showEmpty) {
             $result[$field->getServiceName()] = array('css_class' => $cssFieldName, 'title' => $field->getName(), 'value' => $addressFieldValue);
         }
     }
     return $result;
 }
예제 #2
0
 /**
  * Return Country field value. if no country defined we should use '' value
  *
  * @param \XLite\Model\Address $address Address model (could be shipping or billing address)
  *
  * @return string
  */
 protected function getCountryField($address)
 {
     return $address->getCountry() ? $address->getCountry()->getCode() : '';
 }
예제 #3
0
 /**
  * Get field value
  *
  * @param string               $fieldName    Field name
  * @param \XLite\Model\Address $address      Field name
  * @param boolean              $processValue Process value flag OPTIONAL
  *
  * @return string
  */
 public function getFieldValue($fieldName, \XLite\Model\Address $address, $processValue = false)
 {
     $result = '';
     if (null !== $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:
             }
         }
     }
     return $result;
 }
예제 #4
0
 /**
  * {@inheritDoc}
  */
 public function getCountry()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getCountry', array());
     return parent::getCountry();
 }
예제 #5
0
 /**
  * Prepare the specific data format for address
  *
  * @param \XLite\Model\Address $address Address
  *
  * @return array
  */
 public static function prepareAddressData($address)
 {
     return $address ? array('address' => $address->getStreet(), 'city' => $address->getCity(), 'state' => $address->getState()->getStateId(), 'custom_state' => $address->getCustomState(), 'zipcode' => $address->getZipcode(), 'country' => $address->getCountry() ? $address->getCountry()->getCode() : '', 'type' => $address->getType() ?: \XLite\Core\Config::getInstance()->Shipping->anonymous_address_type) : null;
 }