本文整理汇总了PHP中Mage_Customer_Model_Address_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Customer_Model_Address_Abstract类的具体用法?PHP Mage_Customer_Model_Address_Abstract怎么用?PHP Mage_Customer_Model_Address_Abstract使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Customer_Model_Address_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transferPhysicalAddressPayloadToAddress
/**
* 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;
}
示例2: render
/**
* 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);
}
示例3: getAddressCosts
/**
* 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();
}
}
示例4: copyShipFromAddressTo
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));
}
}
示例5: render
/**
* 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);
}
示例6: getIsoRegionCode
/**
* 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);
}
示例7: render
/**
* 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);
}
示例8: mapFromAddress
/**
* @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;
}
示例9: render
/**
* 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);
}
示例10: saveCustomerAddress
/**
* 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;
}
示例11: getFullname
/**
* 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));
}
示例12: checkAddress
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;
}
示例13: getUsableMethod
/**
* 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();
}
示例14: _getAddressData
/**
* @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;
}
示例15: generateAddressHash
/**
* 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);
}