本文整理汇总了PHP中Varien_Object::getPostcode方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::getPostcode方法的具体用法?PHP Varien_Object::getPostcode怎么用?PHP Varien_Object::getPostcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::getPostcode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getRates
/**
* Returns tax rates for request and when US only uses five digit zip code lookups
*
* @param Varien_Object $request
* @return array
*/
protected function _getRates($request)
{
// Grab each current value
$countryId = $request->getCountryId();
$currentPostcode = $request->getPostcode();
if ($countryId == 'US') {
// Trim whitespace
$newPostcode = preg_replace('/\\s+/', '', $request->getPostcode());
// Snatch only the first five characters
$newPostcode = substr($newPostcode, 0, 5);
// Replace the request's zip code with one that now has 5 digits
$request->setPostcode($newPostcode);
// Find rates by the new 5-digit zip
$rates = parent::_getRates($request);
// Reset the request's postcode to what it was
$request->setPostcode($currentPostcode);
} else {
// Non-US should just work normally
$rates = parent::_getRates($request);
}
return $rates;
}
示例2: _getBillingAddress
/**
* Get billing address request data
*
* @param Varien_Object $address
* @return array
*/
protected function _getBillingAddress(Varien_Object $address)
{
$request = array('billing_first_name' => $address->getFirstname(), 'billing_last_name' => $address->getLastname(), 'billing_city' => $address->getCity(), 'billing_state' => $address->getRegion(), 'billing_zip' => $address->getPostcode(), 'billing_country' => $address->getCountry());
// convert streets to tow lines format
$street = Mage::helper('customer/address')->convertStreetLines($address->getStreet(), 2);
$request['billing_address1'] = isset($street[0]) ? $street[0] : '';
$request['billing_address2'] = isset($street[1]) ? $street[1] : '';
return $request;
}
示例3: collectRatesByAddress
public function collectRatesByAddress(Varien_Object $address, $limitCarrier = null)
{
$request = Mage::getModel('shipping/rate_request');
$request->setDestCountryId($address->getCountryId());
$request->setDestRegionId($address->getRegionId());
$request->setDestPostcode($address->getPostcode());
$request->setPackageValue($address->getSubtotal());
$request->setPackageWeight($address->getWeight());
$request->setPackageQty($address->getItemQty());
$request->setStoreId(Mage::app()->getStore()->getId());
$request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
$request->setBaseCurrency(Mage::app()->getStore()->getBaseCurrency());
$request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency());
$request->setLimitCarrier($limitCarrier);
return $this->collectRates($request);
}
示例4: compareRequests
/**
* Compare data and rates for two tax rate requests for same products (product tax class ids).
* Returns true if requests are similar (i.e. equal taxes rates will be applied to them)
*
* Notice:
* a) productClassId MUST be identical for both requests, because we intend to check selling SAME products to DIFFERENT locations
* b) due to optimization productClassId can be array of ids, not only single id
*
* @param Varien_Object $first
* @param Varien_Object $second
* @return bool
*/
public function compareRequests($first, $second)
{
$country = $first->getCountryId() == $second->getCountryId();
// "0" support for admin dropdown with --please select--
$region = (int) $first->getRegionId() == (int) $second->getRegionId();
$postcode = $first->getPostcode() == $second->getPostcode();
$taxClass = $first->getCustomerClassId() == $second->getCustomerClassId();
if ($country && $region && $postcode && $taxClass) {
return true;
}
/**
* Compare available tax rates for both requests
*/
$firstReqRates = $this->_getResource()->getRateIds($first);
$secondReqRates = $this->_getResource()->getRateIds($second);
if ($firstReqRates === $secondReqRates) {
return true;
}
/**
* If rates are not equal by ids then compare actual values
* All product classes must have same rates to assume requests been similar
*/
$productClassId1 = $first->getProductClassId();
// Save to set it back later
$productClassId2 = $second->getProductClassId();
// Save to set it back later
// Ids are equal for both requests, so take any of them to process
$ids = is_array($productClassId1) ? $productClassId1 : array($productClassId1);
$identical = true;
foreach ($ids as $productClassId) {
$first->setProductClassId($productClassId);
$rate1 = $this->getRate($first);
$second->setProductClassId($productClassId);
$rate2 = $this->getRate($second);
if ($rate1 != $rate2) {
$identical = false;
break;
}
}
$first->setProductClassId($productClassId1);
$second->setProductClassId($productClassId2);
return $identical;
}
示例5: _getRates
/**
* Returns tax rates for request - either pereforms SELECT from DB, or returns already cached result
* Notice that productClassId due to optimization can be array of ids
*
* @param Varien_Object $request
* @return array
*/
protected function _getRates($request)
{
// Extract params that influence our SELECT statement and use them to create cache key
$storeId = Mage::app()->getStore($request->getStore())->getId();
$customerClassId = $request->getCustomerClassId();
$countryId = $request->getCountryId();
$regionId = $request->getRegionId();
$postcode = $request->getPostcode();
// Process productClassId as it can be array or usual value. Form best key for cache.
$productClassId = $request->getProductClassId();
$ids = is_array($productClassId) ? $productClassId : array($productClassId);
foreach ($ids as $key => $val) {
$ids[$key] = (int) $val;
// Make it integer for equal cache keys even in case of null/false/0 values
}
$ids = array_unique($ids);
sort($ids);
$productClassKey = implode(',', $ids);
// Form cache key and either get data from cache or from DB
$cacheKey = implode('|', array($storeId, $customerClassId, $productClassKey, $countryId, $regionId, $postcode));
if (!isset($this->_ratesCache[$cacheKey])) {
// Make SELECT and get data
$select = $this->_getReadAdapter()->select();
$select->from(array('main_table' => $this->getMainTable()), array('tax_calculation_rate_id', 'tax_calculation_rule_id', 'customer_tax_class_id', 'product_tax_class_id'))->where('customer_tax_class_id = ?', (int) $customerClassId);
if ($productClassId) {
$select->where('product_tax_class_id IN (?)', $productClassId);
}
$ifnullTitleValue = $this->_getReadAdapter()->getCheckSql('title_table.value IS NULL', 'rate.code', 'title_table.value');
$ruleTableAliasName = $this->_getReadAdapter()->quoteIdentifier('rule.tax_calculation_rule_id');
$select->join(array('rule' => $this->getTable('tax/tax_calculation_rule')), $ruleTableAliasName . ' = main_table.tax_calculation_rule_id', array('rule.priority', 'rule.position'))->join(array('rate' => $this->getTable('tax/tax_calculation_rate')), 'rate.tax_calculation_rate_id = main_table.tax_calculation_rate_id', array('value' => 'rate.rate', 'rate.tax_country_id', 'rate.tax_region_id', 'rate.tax_postcode', 'rate.tax_calculation_rate_id', 'rate.code'))->joinLeft(array('title_table' => $this->getTable('tax/tax_calculation_rate_title')), "rate.tax_calculation_rate_id = title_table.tax_calculation_rate_id " . "AND title_table.store_id = '{$storeId}'", array('title' => $ifnullTitleValue))->where('rate.tax_country_id = ?', $countryId)->where("rate.tax_region_id IN(?)", array(0, (int) $regionId));
$postcodeIsNumeric = is_numeric($postcode);
if ($postcodeIsNumeric) {
$selectClone = clone $select;
$selectClone->where('rate.zip_is_range IS NOT NULL');
}
$select->where('rate.zip_is_range IS NULL');
if ($request->getPostcode() != '*') {
$select->where("rate.tax_postcode IS NULL OR rate.tax_postcode IN('*', '', ?)", $this->_createSearchPostCodeTemplates($postcode));
if ($postcodeIsNumeric) {
$selectClone->where('? BETWEEN rate.zip_from AND rate.zip_to', $postcode);
}
}
/**
* @see ZF-7592 issue http://framework.zend.com/issues/browse/ZF-7592
*/
if ($postcodeIsNumeric) {
$select = $this->_getReadAdapter()->select()->union(array('(' . $select . ')', '(' . $selectClone . ')'));
}
$select->order('priority ' . Varien_Db_Select::SQL_ASC)->order('tax_calculation_rule_id ' . Varien_Db_Select::SQL_ASC)->order('tax_country_id ' . Varien_Db_Select::SQL_DESC)->order('tax_region_id ' . Varien_Db_Select::SQL_DESC)->order('tax_postcode ' . Varien_Db_Select::SQL_DESC)->order('value ' . Varien_Db_Select::SQL_DESC);
$this->_ratesCache[$cacheKey] = $this->_getReadAdapter()->fetchAll($select);
}
return $this->_ratesCache[$cacheKey];
}
示例6: addShippingAddress
/**
* Assigning shipping address to soap object
*
* @param Varien_Object $shipping
*/
protected function addShippingAddress($shipping)
{
//checking if we have shipping address, in case of virtual order we will not have it
if ($shipping) {
$shipTo = new stdClass();
$shipTo->firstName = $shipping->getFirstname();
$shipTo->lastName = $shipping->getLastname();
$shipTo->company = $shipping->getCompany();
$shipTo->street1 = $shipping->getStreet(1);
$shipTo->street2 = $shipping->getStreet(2);
$shipTo->city = $shipping->getCity();
$shipTo->state = $shipping->getRegion();
$shipTo->postalCode = $shipping->getPostcode();
$shipTo->country = $shipping->getCountry();
$shipTo->phoneNumber = $this->cleanPhoneNum($shipping->getTelephone());
$this->_request->shipTo = $shipTo;
Mage::getSingleton('core/session')->setShipping($shipTo);
}
}
示例7: getApplicableRateIds
/**
* Get rate ids applicable for some address
*
* @param Varien_Object $request
* @return array
*/
function getApplicableRateIds($request)
{
$countryId = $request->getCountryId();
$regionId = $request->getRegionId();
$postcode = $request->getPostcode();
$select = $this->_getReadAdapter()->select()->from(array('rate' => $this->getTable('tax/tax_calculation_rate')), array('tax_calculation_rate_id'))->where('rate.tax_country_id = ?', $countryId)->where("rate.tax_region_id IN(?)", array(0, (int) $regionId));
$expr = $this->_getWriteAdapter()->getCheckSql('zip_is_range is NULL', $this->_getWriteAdapter()->quoteInto("rate.tax_postcode IS NULL OR rate.tax_postcode IN('*', '', ?)", $this->_createSearchPostCodeTemplates($postcode)), $this->_getWriteAdapter()->quoteInto('? BETWEEN rate.zip_from AND rate.zip_to', $postcode));
$select->where($expr);
$select->order('tax_calculation_rate_id');
return $this->_getReadAdapter()->fetchCol($select);
}
示例8: collectRatesByAddress
/**
* Collect rates by address
*
* @param Varien_Object $address
* @param null|bool|array $limitCarrier
* @return Mage_Shipping_Model_Shipping
*/
public function collectRatesByAddress(Varien_Object $address, $limitCarrier = null)
{
/** @var $request Mage_Shipping_Model_Rate_Request */
$request = Mage::getModel('shipping/rate_request');
$request->setAllItems($address->getAllItems());
$request->setDestCountryId($address->getCountryId());
$request->setDestRegionId($address->getRegionId());
$request->setDestPostcode($address->getPostcode());
$request->setPackageValue($address->getBaseSubtotal());
$request->setPackageValueWithDiscount($address->getBaseSubtotalWithDiscount());
$request->setPackageWeight($address->getWeight());
$request->setFreeMethodWeight($address->getFreeMethodWeight());
$request->setPackageQty($address->getItemQty());
$request->setStoreId(Mage::app()->getStore()->getId());
$request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
$request->setBaseCurrency(Mage::app()->getStore()->getBaseCurrency());
$request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency());
$request->setLimitCarrier($limitCarrier);
$request->setBaseSubtotalInclTax($address->getBaseSubtotalInclTax() + $address->getBaseExtraTaxAmount());
return $this->collectRates($request);
}
示例9: getDefaultDestination
private function getDefaultDestination($store = null)
{
$this->log('default dest');
$address = new Varien_Object();
$request = new Varien_Object();
$address->setCountryId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_COUNTRY, $store))->setRegionId(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_REGION, $store))->setPostcode(Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_DEFAULT_POSTCODE, $store));
$customerTaxClass = null;
$customer = $this->getCustomer();
if (is_null($customerTaxClass) && $customer) {
$customerTaxClass = $customer->getTaxClassId();
} elseif ($customerTaxClass === false || !$customer) {
$customerTaxClass = $this->getDefaultCustomerTaxClass($store);
}
$request->setCountryId($address->getCountryId())->setRegionId($address->getRegionId())->setPostcode($address->getPostcode())->setStore($store)->setCustomerClassId($customerTaxClass);
return $request;
}
示例10: _getRates
/**
* Load select and return tax rates
*
* @param Varien_Object $request
* @return array
*/
protected function _getRates($request)
{
$storeId = Mage::app()->getStore($request->getStore())->getId();
$select = $this->_getReadAdapter()->select();
$select->from(array('main_table' => $this->getMainTable()))->where('customer_tax_class_id = ?', $request->getCustomerClassId());
if ($request->getProductClassId()) {
$select->where('product_tax_class_id IN (?)', $request->getProductClassId());
}
$select->join(array('rule' => $this->getTable('tax/tax_calculation_rule')), 'rule.tax_calculation_rule_id = main_table.tax_calculation_rule_id', array('rule.priority', 'rule.position'));
$select->join(array('rate' => $this->getTable('tax/tax_calculation_rate')), 'rate.tax_calculation_rate_id = main_table.tax_calculation_rate_id', array('value' => 'rate.rate', 'rate.tax_country_id', 'rate.tax_region_id', 'rate.tax_postcode', 'rate.tax_calculation_rate_id', 'rate.code'));
$select->joinLeft(array('title_table' => $this->getTable('tax/tax_calculation_rate_title')), "rate.tax_calculation_rate_id = title_table.tax_calculation_rate_id AND title_table.store_id = '{$storeId}'", array('title' => 'IFNULL(title_table.value, rate.code)'));
$select->where("rate.tax_country_id = ?", $request->getCountryId())->where("rate.tax_region_id in ('*', '', ?)", $request->getRegionId());
$selectClone = clone $select;
$select->where("rate.zip_is_range IS NULL")->where("rate.tax_postcode in ('*', '', ?)", $this->_createSearchPostCodeTemplates($request->getPostcode()));
$selectClone->where("rate.zip_is_range IS NOT NULL")->where("? BETWEEN rate.zip_from AND rate.zip_to", $request->getPostcode());
/**
* @see ZF-7592 issue http://framework.zend.com/issues/browse/ZF-7592
*/
$select = $this->_getReadAdapter()->select()->union(array('(' . $select . ')', '(' . $selectClone . ')'));
$order = array('priority ASC', 'tax_calculation_rule_id ASC', 'tax_country_id DESC', 'tax_region_id DESC', 'tax_postcode DESC', 'value DESC');
$select->order($order);
return $this->_getReadAdapter()->fetchAll($select);
}
示例11: createAccessCode
/**
* Create new AccessCode
* @param Varien_Object $billing
* @param Varien_Object $infoInstance
* @param string $method
* @param null $request
* @return Eway_Rapid31_Model_Response
*/
public function createAccessCode(Varien_Object $billing, Varien_Object $infoInstance, $method = 'AccessCodes', $request = null)
{
// Empty Varien_Object's data
$tokenCustomerID = $request->get('TokenCustomerID');
$this->unsetData();
$customerParam = Mage::getModel('ewayrapid/field_customer');
$customerParam->setTokenCustomerID($tokenCustomerID)->setTitle($billing->getPrefix())->setFirstName($billing->getFirstname())->setLastName($billing->getLastname())->setCompanyName($billing->getCompany())->setJobDescription($billing->getJobDescription())->setStreet1($billing->getStreet1())->setStreet2($billing->getStreet2())->setCity($billing->getCity())->setState($billing->getRegion())->setPostalCode($billing->getPostcode())->setCountry(strtolower($billing->getCountryModel()->getIso2Code()))->setEmail($billing->getEmail())->setPhone($billing->getTelephone())->setMobile($billing->getMobile())->setComments('')->setFax($billing->getFax())->setUrl('');
$returnUrl = Mage::getBaseUrl() . '/ewayrapid/mycards/saveToken?ccType=' . $infoInstance->getCcType() . '&expYear=' . $infoInstance->getCcExpYear();
if ($request->get('is_default') == 'on') {
$returnUrl .= '&is_default=on';
}
if ($infoInstance->getCcStartMonth()) {
$returnUrl .= '&startMonth=' . $infoInstance->getCcStartMonth();
}
if ($infoInstance->getCcStartYear()) {
$returnUrl .= '&startYear=' . $infoInstance->getCcStartYear();
}
if ($infoInstance->getCcIssueNumber()) {
$returnUrl .= '&issueNumber=' . $infoInstance->getCcIssueNumber();
}
// Binding address on url param
$returnUrl .= '&street1=' . base64_encode($billing->getStreet1()) . '&street2=' . base64_encode($billing->getStreet2());
$tokenId = $request->get('token_id');
if (!empty($tokenId)) {
// ID token customer will be defined to update
$returnUrl = $returnUrl . '&token_id=' . $tokenId;
}
$this->setCustomer($customerParam);
$this->setRedirectUrl($returnUrl);
$this->setCancelUrl($returnUrl);
$this->setMethod(!empty($tokenCustomerID) ? 'UpdateTokenCustomer' : 'CreateTokenCustomer');
$this->setCustomerIP($_SERVER["REMOTE_ADDR"]);
$this->setDeviceID('');
$this->setTransactionType("Purchase");
$this->setCustomerReadOnly(true);
// Create new access code
//$formMethod = !empty($tokenCustomerID) ? 'PUT' : 'POST';
$response = $this->_doRapidAPI($method);
return $response;
}
示例12: compareRequests
/**
* Compare data from two tax rate requests.
* Return true if requests are semilar
*
* @param Varien_Object $first
* @param Varien_Object $second
* @return bool
*/
public function compareRequests($first, $second)
{
// var_dump($first->getCountryId() , $second->getCountryId()); echo '<br>';
// var_dump($first->getRegionId(), $second->getRegionId());echo '<br>';
$country = $first->getCountryId() == $second->getCountryId();
/**
* "0" support for admin dropdown with --please select--
*/
$region = (int) $first->getRegionId() == (int) $second->getRegionId() || $first->getRegionId() == '*' || $second->getRegionId() == '*' || $first->getRegionId() == '0' || $second->getRegionId() == '0';
$postcode = $first->getPostcode() == $second->getPostcode() || $first->getPostcode() == '*' || $second->getPostcode() == '*';
$taxClass = $first->getCustomerClassId() == $second->getCustomerClassId();
if ($country && $region && $postcode && $taxClass) {
return true;
}
return false;
}
示例13: copy
/**
* Copy address
*
* @param Varien_Object $srcAddress
* @param Varien_Object $dstAddress
* @return Innoexts_Warehouse_Helper_Data
*/
public function copy($srcAddress, $dstAddress)
{
$dstAddress->setCountryId($srcAddress->getCountryId());
$dstAddress->setRegionId($srcAddress->getRegionId());
$dstAddress->setRegion($srcAddress->getRegion());
$dstAddress->setCity($srcAddress->getCity());
$dstAddress->setPostcode($srcAddress->getPostcode());
$dstAddress->setStreet($srcAddress->getStreet());
return $this;
}
示例14: compareRequests
/**
* Compare data and rates for two tax rate requests.
* Return true if requests are semilar
*
* @param Varien_Object $first
* @param Varien_Object $second
* @return bool
*/
public function compareRequests($first, $second)
{
$country = $first->getCountryId() == $second->getCountryId();
/**
* "0" support for admin dropdown with --please select--
*/
$region = (int) $first->getRegionId() == (int) $second->getRegionId();
$postcode = $first->getPostcode() == $second->getPostcode();
$taxClass = $first->getCustomerClassId() == $second->getCustomerClassId();
if ($country && $region && $postcode && $taxClass) {
return true;
}
/**
* Compare available tax rates for both requests
*/
$firstReqRates = $this->_getResource()->getRateIds($first);
$secondReqRates = $this->_getResource()->getRateIds($second);
if ($firstReqRates === $secondReqRates) {
return true;
}
return false;
}
示例15: assignData
/**
* Assign data to info model instance
* Save capayable customer
*
* @param mixed $data
* @return Mage_Payment_Model_Info
*/
public function assignData($data)
{
if (!$data instanceof Varien_Object) {
$data = new Varien_Object($data);
}
$quote = $this->getInfoInstance()->getQuote();
$address = $quote->getBillingAddress();
if (!$quote->getCustomerMiddlename()) {
$quote->setCustomerMiddlename($data->getCustomerMiddlename());
}
if (!$quote->getCustomerGender()) {
$quote->setCustomerGender($data->getCustomerGender());
}
// Convert date format
$dob = $quote->getCustomerDob() ? $quote->getCustomerDob() : $data->getCustomerDob();
$dob = Mage::app()->getLocale()->date($dob, null, null, false)->toString('yyyy-MM-dd 00:00:00');
$data->setCustomerDob($dob);
$quote->setCustomerDob($dob);
$capayableCustomer = Mage::getModel('capayable/customer')->loadByEmail($quote->getCustomerEmail());
/**
* If capayable customer doesn't exist fill new customer data from quote data.
* Otherwise rewrite saved customer fields from form data.
*/
if (!$capayableCustomer->getId()) {
$capayableCustomer->setCustomerEmail($quote->getCustomerEmail())->setCustomerLastname($quote->getCustomerLastname())->setCustomerMiddlename($quote->getCustomerMiddlename())->setCustomerGender($quote->getCustomerGender())->setCustomerDob($quote->getCustomerDob())->setStreet($data->getStreet())->setHouseNumber((int) $data->getHouseNumber())->setHouseSuffix($data->getHouseSuffix())->setPostcode($data->getPostcode())->setCity($data->getCity())->setCountryId($address->getCountryId())->setTelephone($address->getTelephone())->setFax($address->getFax())->setIsCorporation($data->getIsCorporation())->setIsSoleProprietor($data->getIsSoleProprietor())->setCorporationName($data->getCorporationName())->setCocNumber($data->getCocNumber());
} else {
$capayableCustomer->addData($data->getData());
}
// Validate capayable customer required fields
$result = $capayableCustomer->validate();
if (true !== $result && is_array($result)) {
throw new Mage_Payment_Model_Info_Exception(implode(', ', $result));
}
// Save capayable customer to 'capayable/customer' table
$capayableCustomer->save();
$this->getInfoInstance()->addData($data->getData());
return $this;
}