/**
  * Takes a magento address object and generates an array 
  * containing data for gateway request
  *
  * @param Mage_Customer_Model_Address $address
  *
  * @return array
  */
 public function convertAddress($address)
 {
     if ($this->getConfig()->isConsumerCheck()) {
         switch ($address->getCountryId()) {
             case 'AT':
                 $staat = '040';
                 break;
             case 'CH':
                 $staat = '756';
                 break;
             case 'DE':
                 $staat = '280';
                 break;
             default:
                 $staat = '276';
                 break;
         }
     } else {
         $staat = 'DE' == $address->getCountryId() ? '280' : '276';
     }
     $addressData = array($this->_getFirstNameFieldName() => utf8_decode($this->_getFirstNameValue($address)), $this->_getLastNameFieldName() => utf8_decode($this->_getLastNameValue($address)), 'STRASSE' => utf8_decode($this->getStreet(implode(' ', $address->getStreet()))), 'HAUS_NR' => utf8_decode($this->getStreetNumber(implode(' ', $address->getStreet()))), 'ORT' => utf8_decode($address->getCity()), 'PLZ' => utf8_decode($address->getPostcode()), 'STAAT' => $staat);
     return $addressData;
 }
示例#2
0
 /**
  * Collect address data to xml node
  * Remove objects from data array and escape data values
  *
  * @param Mage_Customer_Model_Address $address
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
  * @return Mage_XmlConnect_Block_Checkout_Onepage_Address_List
  */
 protected function _prepareAddressData(Mage_Customer_Model_Address $address, Mage_XmlConnect_Model_Simplexml_Element $item)
 {
     $attributes = Mage::helper('customer/address')->getAttributes();
     $data = array('entity_id' => $address->getId());
     foreach ($attributes as $attribute) {
         /* @var $attribute Mage_Customer_Model_Attribute */
         if (!$attribute->getIsVisible()) {
             continue;
         }
         if ($attribute->getAttributeCode() == 'country_id') {
             $data['country'] = $address->getCountryModel()->getName();
             $data['country_id'] = $address->getCountryId();
         } else {
             if ($attribute->getAttributeCode() == 'region') {
                 $data['region'] = $address->getRegion();
             } else {
                 $dataModel = Mage_Customer_Model_Attribute_Data::factory($attribute, $address);
                 $attributeValue = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ONELINE);
                 if ($attribute->getFrontendInput() == 'multiline') {
                     $values = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ARRAY);
                     // explode lines
                     foreach ($values as $attributeIndex => $attributeVal) {
                         $key = sprintf('%s%d', $attribute->getAttributeCode(), $attributeIndex + 1);
                         $data[$key] = $attributeVal;
                     }
                 }
                 $data[$attribute->getAttributeCode()] = $attributeValue;
             }
         }
     }
     foreach ($data as $key => $value) {
         if (empty($value)) {
             continue;
         }
         $item->addCustomChild($key, $value);
     }
     return $this;
 }
示例#3
0
文件: Data.php 项目: okite11/frames21
 /**
  * Get validation message that will be displayed to user by VAT validation result object
  *
  * @param Mage_Customer_Model_Address $customerAddress
  * @param bool $customerGroupAutoAssignDisabled
  * @param Varien_Object $validationResult
  * @return Varien_Object
  */
 public function getVatValidationUserMessage($customerAddress, $customerGroupAutoAssignDisabled, $validationResult)
 {
     $message = '';
     $isError = true;
     $customerVatClass = $this->getCustomerVatClass($customerAddress->getCountryId(), $validationResult);
     $groupAutoAssignDisabled = Mage::getStoreConfigFlag(self::XML_PATH_CUSTOMER_VIV_GROUP_AUTO_ASSIGN);
     $willChargeTaxMessage = $this->__('You will be charged tax.');
     $willNotChargeTaxMessage = $this->__('You will not be charged tax.');
     if ($validationResult->getIsValid()) {
         $message = $this->__('Your VAT ID was successfully validated.');
         $isError = false;
         if (!$groupAutoAssignDisabled && !$customerGroupAutoAssignDisabled) {
             $message .= ' ' . ($customerVatClass == self::VAT_CLASS_DOMESTIC ? $willChargeTaxMessage : $willNotChargeTaxMessage);
         }
     } else {
         if ($validationResult->getRequestSuccess()) {
             $message = sprintf($this->__('The VAT ID entered (%s) is not a valid VAT ID.') . ' ', $this->escapeHtml($customerAddress->getVatId()));
             if (!$groupAutoAssignDisabled && !$customerGroupAutoAssignDisabled) {
                 $message .= $willChargeTaxMessage;
             }
         } else {
             $contactUsMessage = sprintf($this->__('If you believe this is an error, please contact us at %s'), Mage::getStoreConfig(self::XML_PATH_SUPPORT_EMAIL));
             $message = $this->__('Your Tax ID cannot be validated.') . ' ' . (!$groupAutoAssignDisabled && !$customerGroupAutoAssignDisabled ? $willChargeTaxMessage . ' ' : '') . $contactUsMessage;
         }
     }
     $validationMessageEnvelope = new Varien_Object();
     $validationMessageEnvelope->setMessage($message);
     $validationMessageEnvelope->setIsError($isError);
     return $validationMessageEnvelope;
 }
示例#4
0
文件: Data.php 项目: shabirm/avatax
 /**
  * Get region filter
  *
  * @param Mage_Customer_Model_Address $address
  * @param int                         $storeId
  * @return string|bool
  */
 protected function _getFilterRegion($address, $storeId)
 {
     $filter = false;
     $regionFilters = explode(',', Mage::getStoreConfig('tax/avatax/region_filter_list', $storeId));
     $entityId = $address->getRegionId() ?: $address->getCountryId();
     if (!in_array($entityId, $regionFilters)) {
         $filter = 'region';
     }
     return $filter;
 }
示例#5
0
 /**
  * Import quote address data from customer address object
  *
  * @param   Mage_Customer_Model_Address $address
  * @return  Mage_Sales_Model_Quote_Address
  */
 public function importCustomerAddress(Mage_Customer_Model_Address $address)
 {
     $this->setCustomerAddressId($address->getId())->setCustomerId($address->getParentId())->setEmail($address->hasEmail() ? $address->getEmail() : $address->getCustomer()->getEmail())->setFirstname($address->getFirstname())->setLastname($address->getLastname())->setCompany($address->getCompany())->setStreet($address->getStreet())->setCity($address->getCity())->setRegion($address->getRegion())->setRegionId($address->getRegionId())->setPostcode($address->getPostcode())->setCountryId($address->getCountryId())->setTelephone($address->getTelephone())->setFax($address->getFax());
     return $this;
 }