/**
  * Transfer data from a physical address payload to a Magento address model.
  *
  * @param IPhysicalAddress
  * @param Mage_Customer_Model_Address_Abstract
  * @return self
  */
 public function transferPhysicalAddressPayloadToAddress(IPhysicalAddress $addressPayload, Mage_Customer_Model_Address_Abstract $address)
 {
     /** @var string */
     $region = $addressPayload->getMainDivision();
     $address->setStreet($addressPayload->getLines())->setCity($addressPayload->getCity())->setCountryId($addressPayload->getCountryCode())->setRegionId($this->getRegionIdByCode($region, $addressPayload->getCountryCode()))->setRegion($region)->setPostcode($addressPayload->getPostalCode());
     return $this;
 }
Example #2
0
 /**
  * Render address
  *
  * @param Mage_Customer_Model_Address_Abstract $address
  * @return string
  */
 public function render(Mage_Customer_Model_Address_Abstract $address, $format = null)
 {
     $address->getRegion();
     $address->getCountry();
     $address->explodeStreetAddress();
     $formater = new Varien_Filter_Template();
     $data = $address->getData();
     if ($this->getType()->getHtmlEscape()) {
         foreach ($data as $key => $value) {
             if (is_object($value)) {
                 unset($data[$key]);
             } else {
                 $data[$key] = $this->htmlEscape($value);
             }
         }
     }
     /**
      * Remove data that mustn't show
      */
     if (!$this->helper('customer/address')->canShowConfig('prefix_show')) {
         unset($data['prefix']);
     }
     if (!$this->helper('customer/address')->canShowConfig('middlename_show')) {
         unset($data['middlename']);
     }
     if (!$this->helper('customer/address')->canShowConfig('suffix_show')) {
         unset($data['suffix']);
     }
     $formater->setVariables(array_merge($data, array('country' => $address->getCountryModel()->getName())));
     $format = !is_null($format) ? $format : $this->getFormat($address);
     return $formater->filter($format);
 }
 /**
  * Returns COD fee for certain address
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @return decimal
  *
  */
 public function getAddressCosts(Mage_Customer_Model_Address_Abstract $address)
 {
     if ($address->getCountry() == Mage::getStoreConfig('shipping/origin/country_id')) {
         return $this->getInlandCosts();
     } else {
         return $this->getForeignCountryCosts();
     }
 }
 protected function copyShipFromAddressTo(Mage_Customer_Model_Address_Abstract $address, EbayEnterprise_Inventory_Model_Details_Item $detail)
 {
     if ($detail->isAvailable()) {
         $meta = ['sku' => $detail->getSku(), 'item_id' => $detail->getItemId()];
         $this->logger->debug('applying details for item "{sku}" [{item_id}]', $this->logContext->getMetaData(__CLASS__, $meta));
         $address->addData($this->exportShipFromAddress($detail));
     }
 }
Example #5
0
 /**
  * Check fields
  *
  * @return array|null
  */
 protected function _checkFields()
 {
     /** @var Mage_Checkout_Model_Session $session */
     $session = Mage::getSingleton('checkout/session');
     if ($session->getPostType() == 'onepage') {
         $requiredFields = explode(",", $this->getHelper()->getFieldRequiredList());
         $fieldRules = explode(",", $this->getHelper()->getFieldRule());
         foreach ($requiredFields as $field) {
             $requiredFlag = 0;
             foreach ($fieldRules as $rule) {
                 if (preg_match("/street\\d/", $field)) {
                     $field = "street";
                 }
                 if ($field == "country") {
                     $field = "country_id";
                 }
                 if ($this->_mageAddress->getData($field) == $rule || !$this->_mageAddress->getData($field)) {
                     $requiredFlag = 1;
                 }
             }
             if ($requiredFlag) {
                 $errors = array();
                 $errors[] = $this->__('Invalid ') . $this->__($field);
                 return $errors;
             }
         }
     }
     return null;
 }
Example #6
0
 /**
  * Before object save manipulations
  *
  * @return Mage_Sales_Model_Order_Address
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->getParentId() && $this->getOrder()) {
         $this->setParentId($this->getOrder()->getId());
     }
     return $this;
 }
 /**
  * Render address
  *
  * @param Mage_Customer_Model_Address_Abstract $address
  * @return string
  */
 public function render(Mage_Customer_Model_Address_Abstract $address, $format = null)
 {
     $address->getRegion();
     $address->getCountry();
     $address->explodeStreetAddress();
     $formater = new Varien_Filter_Template();
     $data = $address->getData();
     if ($this->getType()->getHtmlEscape()) {
         foreach ($data as $key => $value) {
             if (is_object($value)) {
                 unset($data[$key]);
             } else {
                 $data[$key] = $this->htmlEscape($value);
             }
         }
     }
     $formater->setVariables(array_merge($data, array('country' => $address->getCountryModel()->getName())));
     $format = !is_null($format) ? $format : $this->getFormat($address);
     return $formater->filter($format);
 }
Example #8
0
 /**
  * extracts the region code in iso format (if possible)
  *
  * @param Mage_Customer_Model_Address_Abstract $address
  *
  * @return string - the regin code in iso format
  */
 public function getIsoRegionCode(Mage_Customer_Model_Address_Abstract $address)
 {
     $regionCode = trim($address->getRegionCode());
     $countryCode = $address->getCountry();
     if ($this->isAlreadyIsoCode($regionCode, $countryCode)) {
         return $regionCode;
     }
     if (0 === strpos($regionCode, $countryCode . '-')) {
         return str_replace($countryCode . '-', '', $regionCode);
     }
     return $this->getRegionCodeFromMapping($countryCode, $regionCode);
 }
Example #9
0
 /**
  * Render address
  *
  * @param Mage_Customer_Model_Address_Abstract $address
  * @return string
  */
 public function render(Mage_Customer_Model_Address_Abstract $address, $format = null)
 {
     switch ($this->getType()->getCode()) {
         case 'html':
             $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_HTML;
             break;
         case 'pdf':
             $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_PDF;
             break;
         case 'oneline':
             $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ONELINE;
             break;
         default:
             $dataFormat = Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_TEXT;
             break;
     }
     $formater = new Varien_Filter_Template();
     $attributes = Mage::helper('customer/address')->getAttributes();
     $data = array();
     foreach ($attributes as $attribute) {
         /* @var $attribute Mage_Customer_Model_Attribute */
         if (!$attribute->getIsVisible()) {
             continue;
         }
         if ($attribute->getAttributeCode() == 'country_id') {
             $data['country'] = $address->getCountryModel()->getName();
         } else {
             if ($attribute->getAttributeCode() == 'region') {
                 $data['region'] = Mage::helper('directory')->__($address->getRegion());
             } else {
                 $dataModel = Mage_Customer_Model_Attribute_Data::factory($attribute, $address);
                 $value = $dataModel->outputValue($dataFormat);
                 if ($attribute->getFrontendInput() == 'multiline') {
                     $values = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ARRAY);
                     // explode lines
                     foreach ($values as $k => $v) {
                         $key = sprintf('%s%d', $attribute->getAttributeCode(), $k + 1);
                         $data[$key] = $v;
                     }
                 }
                 $data[$attribute->getAttributeCode()] = $value;
             }
         }
     }
     if ($this->getType()->getHtmlEscape()) {
         foreach ($data as $key => $value) {
             $data[$key] = $this->escapeHtml($value);
         }
     }
     $formater->setVariables($data);
     $format = !is_null($format) ? $format : $this->getFormat($address);
     return $formater->filter($format);
 }
 /**
  * @param Mage_Customer_Model_Address_Abstract $address
  * @return Payone_Api_Request_Consumerscore
  */
 public function mapFromAddress(Mage_Customer_Model_Address_Abstract $address)
 {
     $factory = $this->getFactory();
     $request = $factory->getRequestVerificationConsumerScore();
     $helper = $this->helper();
     $configGlobal = $this->getConfigGlobal();
     $config = $this->getConfig();
     $request->setConsumerscoretype($config->getType());
     $request->setAddresschecktype(Payone_Api_Enum_AddressCheckType::NONE);
     $request->setAid($configGlobal->getAid());
     $request->setMid($configGlobal->getMid());
     $request->setMode($config->getMode());
     $request->setPortalid($configGlobal->getPortalid());
     $request->setKey($configGlobal->getKey());
     $request->setCity($address->getCity());
     $request->setCompany($address->getCompany());
     $request->setCountry($address->getCountry());
     $request->setFirstname($address->getFirstname());
     $request->setLastname($address->getLastname());
     $request->setIntegratorName('Magento');
     $request->setIntegratorVersion($helper->getMagentoVersion());
     $request->setSolutionName('votum');
     $request->setSolutionVersion($helper->getPayoneVersion());
     if ($customerId = $address->getCustomerId()) {
         $customer = $factory->getModelCustomer();
         $customer->load($customerId);
         $date = $customer->getDob();
         $date = date('Ymd', strtotime($date));
         $request->setBirthday($date);
     }
     $request->setEncoding('UTF-8');
     $request->setLanguage($helper->getDefaultLanguage());
     $request->setStreet($address->getStreetFull());
     $request->setTelephonenumber($address->getTelephone());
     $request->setZip($address->getPostcode());
     return $request;
 }
Example #11
0
 /**
  * Render address
  *
  * @param Mage_Customer_Model_Address_Abstract $address
  * @return string
  */
 public function render(Mage_Customer_Model_Address_Abstract $address)
 {
     $format = $this->getType()->getDefaultFormat();
     $countryFormat = $address->getCountryModel()->getFormat($this->getType()->getCode());
     $address->getRegion();
     $address->getCountry();
     $address->explodeStreetAddress();
     if ($countryFormat) {
         $format = $countryFormat->getFormat();
     }
     $formater = new Varien_Filter_Template();
     $formater->setVariables(array_merge($address->getData(), array('country' => $address->getCountryModel()->getName())));
     return $formater->filter($format);
 }
 /**
  * Store date and score to customerAddress.
  * If the quoteAddress is not a saved customerAddress we do nothing
  * If it gets saved to the addressBook at end of checkout Magento´ convert functionality saves the data for us
  *
  * @param Mage_Customer_Model_Address_Abstract $address
  * @return bool
  */
 public function saveCustomerAddress(Mage_Customer_Model_Address_Abstract $address)
 {
     $customerAddressId = $address->getCustomerAddressId();
     if (empty($customerAddressId)) {
         return false;
     }
     $customerAddress = $this->getFactory()->getModelCustomerAddress();
     $customerAddress->load($customerAddressId);
     if (!$customerAddress->hasData()) {
         return false;
     }
     $customerAddress->setData($this->prefix . '_score', $address->getData($this->prefix . '_score'));
     $customerAddress->setData($this->prefix . '_date', $address->getData($this->prefix . '_date'));
     $customerAddress->setData($this->prefix . '_hash', $address->getData($this->prefix . '_hash'));
     $customerAddress->setCity($address->getCity());
     $customerAddress->setStreetFull($address->getStreetFull());
     $customerAddress->setZip($address->getZip());
     $customerAddress->save();
     return true;
 }
Example #13
0
 /**
  * Get fullname from address
  * @param Mage_Customer_Model_Address_Abstract $address
  * @return string
  */
 public function getFullname($address)
 {
     $parts = array();
     if ($address->getFirstname()) {
         $parts[] = $address->getFirstname();
     }
     if ($address->getMiddlename()) {
         $parts[] = $address->getMiddlename();
     }
     if ($address->getLastname()) {
         $parts[] = $address->getLastname();
     }
     if (empty($parts)) {
         return trim(Mage::getSingleton('customer/session')->getCustomer()->getName());
     }
     return trim(join(' ', $parts));
 }
 protected function checkAddress(Mage_Customer_Model_Address_Abstract $address, $validityInSeconds)
 {
     if (!$address->hasData()) {
         return false;
     }
     $savedDate = $address->getData($this->prefix . '_date');
     $savedScore = $address->getData($this->prefix . '_score');
     if (empty($savedDate) or empty($savedScore)) {
         return false;
     }
     if ($this->addressHasChanged($address)) {
         return false;
     }
     // Verify the validity period is not expired:
     if (!$this->helper()->isDateStillValid($savedDate, $validityInSeconds)) {
         return false;
     }
     $address->setData($this->prefix . '_score', $savedScore);
     return $savedScore;
 }
 /**
  * get a magento shipping method identifer for either:
  * - the shipping method used by $address
  * - the first of all valid shipping methods
  *
  * @param Mage_Customer_Model_Address_Abstract
  * @return string
  */
 public function getUsableMethod(Mage_Customer_Model_Address_Abstract $address)
 {
     $this->fetchAvailableShippingMethods();
     return $address->getShippingMethod() ?: $this->getFirstAvailable();
 }
 /**
  * Delete customer address
  *
  * @return Mage_Customer_Model_Address
  */
 public function delete()
 {
     parent::delete();
     $this->setData(array());
     return $this;
 }
 /**
  * @param Mage_Customer_Model_Address_Abstract $address
  * @return array
  */
 protected function _getAddressData(Mage_Customer_Model_Address_Abstract $address)
 {
     $data = array();
     if ($address) {
         $data['name'] = $address->getName();
         $data['address'] = $address->getStreetFull();
         $data['city'] = $address->getCity();
         $data['postcode'] = $address->getPostcode();
         $data['country'] = $address->getCountry();
         $data['state'] = $address->getRegion() ? $address->getRegion() : '';
     }
     return $data;
 }
Example #18
0
 /**
  * generates hash from address data
  *
  * @param Mage_Sales_Model_Quote_Address $address the address data to hash
  *
  * @returns sha1 hash of address
  */
 public function generateAddressHash(Mage_Customer_Model_Address_Abstract $address)
 {
     $addressString = $address->getFirstname();
     $addressString .= $address->getMiddlename();
     $addressString .= $address->getLastname();
     $addressString .= $address->getCompany();
     $street = $address->getStreetFull();
     if (is_array($street)) {
         $street = implode('', $street);
     }
     $addressString .= $street;
     $addressString .= $address->getPostcode();
     $addressString .= $address->getCity();
     $addressString .= $address->getCountryId();
     return sha1($addressString);
 }
Example #19
0
 /**
  * Convert object to array
  *
  * @param   array $arrAttributes
  * @return  array
  */
 public function toArray(array $arrAttributes = array())
 {
     $arr = parent::toArray($arrAttributes);
     $arr['rates'] = $this->getShippingRatesCollection()->toArray($arrAttributes);
     $arr['items'] = $this->getItemsCollection()->toArray($arrAttributes);
     foreach ($this->getTotals() as $k => $total) {
         $arr['totals'][$k] = $total->toArray();
     }
     return $arr;
 }
 /**
  * Extract array of address data - street, city, region code, etc. from an address object
  * @param  Mage_Customer_Model_Address_Abstract $address Address object to pull data from
  * @return array Extracted data
  */
 protected function _extractAddressData(Mage_Customer_Model_Address_Abstract $address)
 {
     return array('street' => $address->getStreet(), 'city' => $address->getCity(), 'region_code' => $address->getRegionCode(), 'country_id' => $address->getCountryId(), 'postcode' => $address->getPostcode());
 }
 /**
  * Check for an order address to be a billing address.
  *
  * @param Mage_Customer_Model_Address_Abstract
  * @return bool
  */
 protected function _isAddressBilling(Mage_Customer_Model_Address_Abstract $address)
 {
     return $address->getAddressType() === Mage_Customer_Model_Address_Abstract::TYPE_BILLING;
 }
Example #22
0
 /**
  * Retrieves street name, house number and house number extension from the shipping address.
  * The shipping address may be in multiple street lines configuration or single line configuration. In the case of
  * multi-line, each part of the street data will be in a separate field. In the single line configuration, each part
  * will be in the same field and will have to be split using PREG.
  *
  * @param Mage_Customer_Model_Address_Abstract $address
  *
  * @return array
  */
 public function getStreetData($address)
 {
     $fullStreet = $address->getStreetFull();
     if ($address->getCountry() != 'NL') {
         $fullStreet = $this->_getInternationalFullStreet($address);
         $streetData = array('streetname' => $fullStreet, 'housenumber' => '', 'housenumberExtension' => '', 'fullStreet' => '');
         return $streetData;
     }
     /**
      * Split the address using PREG.
      * @var TIG_MyParcel2014_Helper_Data $this
      */
     $streetData = $this->_getSplitStreetData($fullStreet);
     return $streetData;
 }
 /**
  * Determine if an order should be sent to ROM as a test order by checking the second street
  * address if it match the constant value IOrderCreateRequest::TEST_TYPE_AUTOCANCEL, then it is
  * a test order, otherwise it is not a test order.
  *
  * @param  Mage_Customer_Model_Address_Abstract
  * @return bool
  */
 protected function isTestOrder(Mage_Customer_Model_Address_Abstract $billingAddress)
 {
     return $billingAddress->getStreet(2) === IOrderCreateRequest::TEST_TYPE_AUTOCANCEL;
 }
 /**
  * Transfer data from a Magento customer address to a ROM SDK
  * PhysicalAddress payload.
  *
  * @param Mage_Customer_Model_Address_Abstract
  * @param IPhysicalAddress
  * @return IPhysicalAddress
  */
 public function customerAddressToPhysicalAddressPayload(Mage_Customer_Model_Address_Abstract $address, IPhysicalAddress $payload)
 {
     return $payload->setLines($address->getStreetFull())->setCity($address->getCity())->setMainDivision($address->getRegionId())->setCountryCode($address->getCountryId())->setPostalCode($address->getPostcode());
 }
 /**
  * Check for the item to have shipping origin data set.
  *
  * @return bool
  */
 protected function isValidPhysicalAddress(Mage_Customer_Model_Address_Abstract $address)
 {
     return $address->getStreet1() && $address->getCity() && $address->getCountryId();
 }
Example #26
0
 /**
  * Get Weee amounts associated with a product
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_Customer_Model_Address_Abstract $shipping
  * @param Mage_Customer_Model_Address_Abstract $billing
  * @param mixed $website
  * @param boolean $calculateTax
  * @param boolean $ignoreDiscount
  * @return array|\Varien_Object
  */
 public function getProductWeeeAttributes($product, $shipping = null, $billing = null, $website = null, $calculateTax = null, $ignoreDiscount = false)
 {
     $result = array();
     $allWeee = $this->getWeeeTaxAttributeCodes();
     if (!$allWeee) {
         return $result;
     }
     $websiteId = Mage::app()->getWebsite($website)->getId();
     $store = Mage::app()->getWebsite($website)->getDefaultGroup()->getDefaultStore();
     $customer = null;
     if ($shipping) {
         $customerTaxClass = $shipping->getQuote()->getCustomerTaxClassId();
         $customer = $shipping->getQuote()->getCustomer();
     } else {
         $customerTaxClass = null;
     }
     $calculator = Mage::getModel('tax/calculation');
     if ($customer) {
         $calculator->setCustomer($customer);
     }
     $rateRequest = $calculator->getRateRequest($shipping, $billing, $customerTaxClass, $store);
     $currentPercent = $product->getTaxPercent();
     if (!$currentPercent) {
         $currentPercent = Mage::getSingleton('tax/calculation')->getRate($rateRequest->setProductClassId($product->getTaxClassId()));
     }
     $discountPercent = 0;
     if (!$ignoreDiscount && Mage::helper('weee')->isDiscounted($store)) {
         $discountPercent = $this->_getDiscountPercentForProduct($product);
     }
     $productAttributes = $product->getTypeInstance(true)->getSetAttributes($product);
     foreach ($productAttributes as $code => $attribute) {
         if (in_array($code, $allWeee)) {
             $attributeSelect = $this->getResource()->getReadConnection()->select();
             $attributeSelect->from($this->getResource()->getTable('weee/tax'), 'value')->where('attribute_id = ?', (int) $attribute->getId())->where('website_id IN(?)', array($websiteId, 0))->where('country = ?', $rateRequest->getCountryId())->where('state IN(?)', array($rateRequest->getRegionId(), '*'))->where('entity_id = ?', (int) $product->getId())->limit(1);
             $order = array('state ' . Varien_Db_Select::SQL_DESC, 'website_id ' . Varien_Db_Select::SQL_DESC);
             $attributeSelect->order($order);
             $value = $this->getResource()->getReadConnection()->fetchOne($attributeSelect);
             if ($value) {
                 if ($discountPercent) {
                     $value = Mage::app()->getStore()->roundPrice($value - $value * $discountPercent / 100);
                 }
                 $taxAmount = 0;
                 $amount = $value;
                 if ($calculateTax && Mage::helper('weee')->isTaxable($store)) {
                     if ($this->_taxHelper->isCrossBorderTradeEnabled($store)) {
                         $defaultPercent = $currentPercent;
                     } else {
                         $defaultRateRequest = $calculator->getDefaultRateRequest($store);
                         $defaultPercent = Mage::getModel('tax/calculation')->getRate($defaultRateRequest->setProductClassId($product->getTaxClassId()));
                     }
                     if (Mage::helper('weee')->isTaxIncluded($store)) {
                         $taxAmount = Mage::app()->getStore()->roundPrice($value / (100 + $defaultPercent) * $currentPercent);
                         $amount = $amount - $taxAmount;
                     } else {
                         $appliedRates = Mage::getModel('tax/calculation')->getAppliedRates($rateRequest);
                         if (count($appliedRates) > 1) {
                             $taxAmount = 0;
                             foreach ($appliedRates as $appliedRate) {
                                 $taxRate = $appliedRate['percent'];
                                 $taxAmount += Mage::app()->getStore()->roundPrice($value * $taxRate / 100);
                             }
                         } else {
                             $taxAmount = Mage::app()->getStore()->roundPrice($value * $currentPercent / 100);
                         }
                     }
                 }
                 $one = new Varien_Object();
                 $one->setName(Mage::helper('catalog')->__($attribute->getFrontend()->getLabel()))->setAmount($amount)->setTaxAmount($taxAmount)->setCode($attribute->getAttributeCode());
                 $result[] = $one;
             }
         }
     }
     return $result;
 }
Example #27
0
 /**
  * @param Mage_Customer_Model_Address_Abstract|Mage_Sales_Model_Abstract $magentoObject
  * @param ShopgateOrder|ShopgateAddress|ShopgateCustomer                 $shopgateObject
  * @return mixed
  */
 public function setCustomFields($magentoObject, $shopgateObject)
 {
     foreach ($shopgateObject->getCustomFields() as $field) {
         $magentoObject->setData($field->getInternalFieldName(), $field->getValue());
     }
     return $magentoObject;
 }
 /**
  * @param Mage_Customer_Model_Address_Abstract $address
  *
  * @return Payone_Api_Request_AddressCheck
  */
 public function mapFromAddress(Mage_Customer_Model_Address_Abstract $address)
 {
     $request = $this->getFactory()->getRequestVerificationAddressCheck();
     $helper = $this->helper();
     $configGlobal = $this->getConfigGlobal();
     $config = $this->getConfig();
     // @todo move addressCheckType detection to method
     // @todo add option to configure used Adresschecktype externaly
     if ($address->getAddressType() === 'billing') {
         $request->setAddresschecktype($config->getCheckBilling());
         // check if billing is used for shipping and shipping-address has to be checked
         if ($address->getUseForShipping() === true and $config->mustCheckShipping()) {
             $request->setAddresschecktype($config->getCheckShipping());
         }
     } elseif ($address->getAddressType() === 'shipping') {
         $request->setAddresschecktype($config->getCheckShipping());
     } else {
         throw new Exception('Invalid Address Check Type');
     }
     $request->setAid($configGlobal->getAid());
     $request->setMid($configGlobal->getMid());
     $request->setMode($config->getMode());
     $request->setPortalid($configGlobal->getPortalid());
     $request->setKey($configGlobal->getKey());
     $request->setCity($address->getCity());
     $request->setCompany($address->getCompany());
     $request->setCountry($address->getCountry());
     $request->setFirstname($address->getFirstname());
     $request->setLastname($address->getLastname());
     $request->setIntegratorName('Magento');
     $request->setIntegratorVersion($helper->getMagentoVersion());
     $request->setSolutionName('votum');
     $request->setSolutionVersion($helper->getPayoneVersion());
     $request->setEncoding('UTF-8');
     $request->setLanguage($helper->getDefaultLanguage());
     $request->setStreet($address->getStreetFull());
     $request->setTelephonenumber($address->getTelephone());
     $countryId = $address->getCountryId();
     if ($countryId == "US" || $countryId == "CA") {
         $request->setState($address->getRegionCode());
     }
     $request->setZip($address->getPostcode());
     return $request;
 }
Example #29
0
 /**
  * Before object save manipulations
  *
  * @return Mage_Sales_Model_Order_Address
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->getParentId() && $this->getOrder()) {
         $this->setParentId($this->getOrder()->getId());
     }
     // Init customer address id if customer address is assigned
     if ($this->getCustomerAddress()) {
         $this->setCustomerAddressId($this->getCustomerAddress()->getId());
     }
     return $this;
 }
Example #30
0
 protected function _beforeDelete()
 {
     parent::_beforeDelete();
     $this->getItemsCollection()->walk('delete');
     $this->getShippingRatesCollection()->walk('delete');
 }