本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request::getDestPostcode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request::getDestPostcode方法的具体用法?PHP Mage_Shipping_Model_Rate_Request::getDestPostcode怎么用?PHP Mage_Shipping_Model_Rate_Request::getDestPostcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Shipping_Model_Rate_Request
的用法示例。
在下文中一共展示了Mage_Shipping_Model_Rate_Request::getDestPostcode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setRequest
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
if ($request->getLimitMethod()) {
$r->setService($request->getLimitMethod());
}
if ($request->getTntAccount()) {
$r->setTntAccount($request->getTntAccount());
} else {
$r->setTntAccount($this->getConfigData('account'));
}
if ($request->getExpZipCode()) {
$r->setExpZipCode($request->getExpZipCode());
} else {
$r->setExpZipCode(Mage::getStoreConfig('carriers/tnt/code_postal', $this->getStore()));
}
if ($request->getExpCity()) {
$r->setExpCity($request->getExpCity());
} else {
$r->setExpCity(Mage::getStoreConfig('carriers/tnt/ville', $this->getStore()));
}
if ($request->getDestPostcode()) {
$r->setDestPostcode($request->getDestPostcode());
} else {
}
if ($request->getDestCity()) {
$r->setDestCity($request->getDestCity());
} else {
}
$this->_rawRequest = $r;
return $this;
}
示例2: setRequest
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
if ($request->getLimitMethod()) {
$r->setService($request->getLimitMethod());
}
if ($request->getFedexAccount()) {
$account = $request->getFedexAccount();
} else {
$account = $this->getConfigData('account');
}
$r->setAccount($account);
if ($request->getFedexDropoff()) {
$dropoff = $request->getFedexDropoff();
} else {
$dropoff = $this->getConfigData('dropoff');
}
$r->setDropoffType($dropoff);
if ($request->getFedexPackaging()) {
$packaging = $request->getFedexPackaging();
} else {
$packaging = $this->getConfigData('packaging');
}
$r->setPackaging($packaging);
if ($request->getOrigCountry()) {
$origCountry = $request->getOrigCountry();
} else {
$origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
}
$r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code());
if ($request->getOrigPostcode()) {
$r->setOrigPostal($request->getOrigPostcode());
} else {
$r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()));
}
if ($request->getDestCountryId()) {
$destCountry = $request->getDestCountryId();
} else {
$destCountry = self::USA_COUNTRY_ID;
}
$r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code());
if ($request->getDestPostcode()) {
$r->setDestPostal($request->getDestPostcode());
} else {
}
$r->setWeight($request->getPackageWeight());
if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
$r->setFreeMethodWeight($request->getFreeMethodWeight());
}
$r->setValue($request->getPackageValue());
$this->_rawRequest = $r;
return $this;
}
示例3: collectRates
/**
* Collects the shipping rates for Australia Post from the REST API.
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Rate_Result|bool
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
// Check if this method is active
if (!$this->getConfigFlag('active')) {
return false;
}
// Check if this method is even applicable (shipping from Australia)
$origCountry = Mage::getStoreConfig('shipping/origin/country_id', $request->getStore());
if ($origCountry != Fontis_Australia_Helper_Data::AUSTRALIA_COUNTRY_CODE) {
return false;
}
if ($this->_client == null) {
return false;
}
$fromPostcode = (int) Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$toPostcode = (int) $request->getDestPostcode();
$destCountry = $request->getDestCountryId();
if (!$destCountry) {
$destCountry = Fontis_Australia_Helper_Data::AUSTRALIA_COUNTRY_CODE;
}
/** @var Fontis_Australia_Helper_Australiapost $helper */
$helper = Mage::helper('australia/australiapost');
$weight = (int) $request->getPackageWeight();
$length = (int) $helper->getAttribute($request, 'length');
$width = (int) $helper->getAttribute($request, 'width');
$height = (int) $helper->getAttribute($request, 'height');
$extraCover = max((int) $request->getPackageValue(), self::EXTRA_COVER_LIMIT);
$config = array('from_postcode' => $fromPostcode, 'to_postcode' => $toPostcode, 'length' => $length, 'width' => $width, 'height' => $height, 'weight' => $weight, 'country_code' => $destCountry);
$this->_getQuotes($extraCover, $config);
$_result = $this->_result->asArray();
if (empty($_result)) {
return false;
}
return $this->_result;
}
示例4: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
$result = Mage::getModel('shipping/rate_result');
$rawPostcode = $request->getDestPostcode();
$postCode = Mage::helper('freight')->validatePostcode($rawPostcode);
if (empty($postCode)) {
return $result;
}
$packageWeight = $request->getPackageWeight();
$shipping = Mage::getModel('freight/config')->getShippingPrice($this->_code, $postCode, $packageWeight);
if ($shipping != null) {
$shippingDeliveryPrice = $shipping->getData('delivery_price') / 100;
$shippingDeliveryTime = $shipping->getData('delivery_time');
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod($this->_code);
$method->setMethodTitle($this->getConfigData('name') . Mage::helper('freight')->formatShippingTime($shippingDeliveryTime));
$method->setPrice($shippingDeliveryPrice);
$method->setCost($shippingDeliveryPrice);
$result->append($method);
}
return $result;
}
示例5: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
//Desabilitado
return false;
}
$result = Mage::getModel('shipping/rate_result');
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$packagevalue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
$frompcode = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$topcode = $request->getDestPostcode();
// if(!preg_match("/^[0-9]{8}$/", $topcode))
// {
// //CEP está errado
// $error->setErrorMessage('O CEP está errado');
// $result->append($error);
// Mage::helper('customer')->__('Invalid ZIP CODE');
// return $result;
// }
//die('dfgf');
$sweight = $request->getPackageWeight();
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setCarrierTitle($this->getConfigData('name'));
$method->setMethod('sedex');
$method->setMethodTitle('Sedex');
$method->setPrice(10 + $this->getConfigData('handling_fee'));
$method->setCost(10);
$result->append($method);
$this->_result = $result;
$this->_updateFreeMethodQuote($request);
return $this->_result;
}
示例6: _getCourierRate
protected function _getCourierRate(Mage_Shipping_Model_Rate_Request $request)
{
$package_cost = $request->getPackageValueWithDiscount();
$shipping_settings = Mage::helper('altteam_qwintry')->getShippingSettings();
$pounds = $request->getPackageWeight();
$currencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
$currency = $request->getPackageCurrency();
if (in_array('USD', $currencies)) {
Mage::helper('directory')->currencyConvert($package_cost, $currency->getCurrencyCode(), 'USD');
} elseif ($currency->getCurrencyCode() == 'EUR') {
$package_cost = $package_cost * 1.097;
} elseif ($currency->getCurrencyCode() == 'RMB') {
$package_cost = $package_cost * 1.157;
}
$data = array('params' => array('method' => 'qwair', 'hub_code' => empty($shipping_settings['hub']) ? 'DE1' : $shipping_settings['hub'], 'insurance' => false, 'retail_pricing' => false, 'weight' => $pounds > 0.1 ? $pounds : (empty($shipping_settings['default_weight']) ? 4 : $shipping_settings['default_weight']), 'items_value' => $package_cost, 'addr_country' => $request->getDestCountryId(), 'addr_zip' => $request->getDestPostcode(), 'addr_line1' => $request->getDestStreet(), 'addr_line2' => '', 'addr_city' => $request->getDestCity(), 'addr_state' => $request->getDestRegionCode()));
$response = Mage::helper('altteam_qwintry')->sendApiRequest('cost', $data);
if (!$response || empty($response->success) || !$response->success) {
return false;
}
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod('courier');
$rate->setMethodTitle('Courier');
$rate->setPrice($response->result->total);
$rate->setCost(0);
return $rate;
}
示例7: getRate
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
$read = $this->_getReadAdapter();
$write = $this->_getWriteAdapter();
$select = $read->select()->from($this->getMainTable());
/*
//commented out code since we don't want to get state by using zip code
if (!$request->getDestCountryId() && !$request->getDestRegionId()) {
// assuming that request is coming from shopping cart
// for shipping prices pre-estimation...
// also probably it will be required to move this part to
// Sales/Model/Quote/Address.php !
$selectCountry = $read->select()->from(Mage::getSingleton('core/resource')->getTableName('usa/postcode'), array('country_id', 'region_id'));
$selectCountry->where('postcode=?', $request->getDestPostcode());
$selectCountry->limit(1);
$countryRegion = $read->fetchRow($selectCountry);
$region = $read->quote($countryRegion['region_id']);
$country = $read->quote($countryRegion['country_id']);
} else {
$region = $read->quote($request->getDestRegionId());
$country = $read->quote($request->getDestCountryId());
}
*/
$region = $read->quote($request->getDestRegionId());
$country = $read->quote($request->getDestCountryId());
$zip = $read->quote($request->getDestPostcode());
$select->where("(dest_zip={$zip})\n OR (dest_region_id={$region} AND dest_zip='')\n OR (dest_country_id={$country} AND dest_region_id='0' AND dest_zip='')\n OR (dest_country_id='0' AND dest_region_id='0' AND dest_zip='')");
if (is_array($request->getConditionName())) {
$i = 0;
foreach ($request->getConditionName() as $conditionName) {
if ($i == 0) {
$select->where('condition_name=?', $conditionName);
} else {
$select->orWhere('condition_name=?', $conditionName);
}
$select->where('condition_value<=?', $request->getData($conditionName));
$i++;
}
} else {
$select->where('condition_name=?', $request->getConditionName());
$select->where('condition_value<=?', $request->getData($request->getConditionName()));
}
$select->where('website_id=?', $request->getWebsiteId());
$select->order('condition_value DESC')->limit(1);
$row = $read->fetchRow($select);
return $row;
}
示例8: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->isActive()) {
return false;
}
$valids = $this->getConfigData('aceita');
if ($valids == 'AMBOS') {
$valids = array('PAC', 'Sedex');
} else {
$valids = array($valids);
}
$result = Mage::getModel('shipping/rate_result');
$method = Mage::getModel('shipping/rate_result_method');
$peso = $request->getPackageWeight();
$destino = $request->getDestPostcode();
$valor = $request->getPackageValue();
$frete = $this->pegaFrete($peso, $destino, $valor);
// Peso, destino, valor
if (in_array('Sedex', $valids)) {
$method->setCarrier($this->_code);
$method->setCarrierTitle('PagSeguro');
$method->setMethod($this->_code . ':Sedex');
$method->setMethodTitle('Sedex');
$method->setPrice($frete['Sedex']);
$result->append($method);
}
// Setando valores para PAC
if (in_array('PAC', $valids)) {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setCarrierTitle('PagSeguro');
$method->setMethod($this->_code . ':PAC');
$method->setMethodTitle('PAC');
$method->setPrice($frete['PAC']);
$result->append($method);
}
/*
}else{
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle("PagSeguro");
$error->setErrorMessage(utf8_encode($frete));
return $error;
}*/
return $result;
}
示例9: getShippingRate
/**
* @param Mage_Shipping_Model_Rate_Request $request
* @return false|Mage_Core_Model_Abstract
*/
protected function getShippingRate(Mage_Shipping_Model_Rate_Request $request)
{
$helper = Mage::helper('etrans');
$address = $helper->formatAddress($request->getDestStreet());
if ($request->getDestCity()) {
$city = $request->getDestCity();
} else {
$city = '-';
}
$data = array('calle' => $address['street'], 'numero_puerta' => $address['number'], 'piso' => '', 'dpto_oficina' => '', 'bque_torre' => '', 'cp' => $request->getDestPostcode(), 'localidad' => $city, 'partido' => '', 'provincia' => $this->getRegionName($request->getDestRegionId()), 'email' => 'guest@example.com', 'celular' => '', 'nombre_razon_social' => 'Guest', 'dni_cuit' => '', 'telefono' => '', 'seguro' => $this->getConfigData('insurance'), 'horario_retiro' => $this->getConfigData('pickup_time'), 'horario_entrega' => $this->getConfigData('delivery_time'));
$items = $request->getAllItems();
if ($items) {
$i = 1;
foreach ($items as $item) {
$item_qty = (int) $item->getQty();
$dimensions = $helper->getProductDimensions($item->getProductId());
if ($item_qty > 1) {
$item_number = 1;
while ($item_number <= $item_qty) {
$data['bulto_' . $i] = array('alto' => $dimensions['height'], 'ancho' => $dimensions['width'], 'profundidad' => $dimensions['depth'], 'peso' => $dimensions['weight'], 'valor_declarado' => $dimensions['price']);
$i++;
$item_number++;
}
} else {
$data['bulto_' . $i] = array('alto' => $dimensions['height'], 'ancho' => $dimensions['width'], 'profundidad' => $dimensions['depth'], 'peso' => $dimensions['weight'], 'valor_declarado' => $dimensions['price']);
}
$i++;
}
}
$etrans = new Dc_Etrans_Client($this->getConfigData('api_key'), $this->getConfigData('api_secret'));
$response = $etrans->crear_parametros($data);
if (is_array($response) && !empty($response['response']['response']['Costo'])) {
$rate = Mage::getModel('shipping/rate_result_method');
$rate->setCarrier($this->_code);
$rate->setCarrierTitle($this->getConfigData('title'));
$rate->setMethod('standand');
$rate->setMethodTitle($this->getConfigData('name'));
$rate->setPrice($response['response']['response']['Costo']);
$rate->setCost(0);
return $rate;
} else {
return false;
}
}
示例10: getRates
/**
* Recupera os preços de frete baseado no request do usuário
* @param Mage_Shipping_Model_Rate_Request $request
* @return multitype:unknown
*/
public function getRates(Mage_Shipping_Model_Rate_Request $request)
{
$read = $this->_getReadAdapter();
$write = $this->_getWriteAdapter();
$postcode = Mage::helper('av5_correios')->_formatZip($request->getDestPostcode());
$table = Mage::getSingleton('core/resource')->getTableName('av5_correios_shipping/correios');
$pkgWeight = ceil($request->getPackageWeight());
$searchString = " AND (cep_destino_ini <= '" . $postcode . "' AND cep_destino_fim >= '" . $postcode . "') AND peso = '" . $pkgWeight . "'";
$select = $read->select()->from($table);
$select->where($read->quoteInto(" ( servico in (?) ) ", $request->getPostingMethods()) . $searchString);
$newdata = array();
$row = $read->fetchAll($select);
if (!empty($row)) {
foreach ($row as $data) {
$newdata[] = $data;
}
}
return $newdata;
}
示例11: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
$cep = $request->getDestPostcode();
$totalPedido = $request->getPackageValue();
$result = Mage::getModel('shipping/rate_result');
if ($this->getConfigData('active') && (!$this->getConfigData('valor_pedido') || $totalPedido >= $this->getConfigData('valor_pedido'))) {
if ($this->cepNaFaixa($cep) && $this->getConfigData('frete_gratis_por_faixa') || !$this->getConfigData('frete_gratis_por_faixa')) {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod($this->_code);
$method->setMethodTitle($this->_name);
$method->setPrice('0.00');
$method->setCost('0.00');
$result->append($method);
}
}
return $result;
}
示例12: proccessAdditionalValidation
public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request)
{
if (!count($request->getAllItems())) {
return $this;
}
$errorMsg = '';
$configErrorMsg = $this->getConfigData('specificerrmsg');
$defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.');
$showMethod = $this->getConfigData('showmethod');
if (!$errorMsg && !$request->getDestPostcode() && $this->isZipCodeRequired()) {
$errorMsg = Mage::helper('shipping')->__('This shipping method is not available, please specify ZIP-code');
}
if ($errorMsg && $showMethod) {
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$error->setErrorMessage($errorMsg);
return $error;
} elseif ($errorMsg) {
return false;
}
return $this;
}
示例13: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
return false;
}
$destinationData = array('city' => ucwords(strtolower($request->getDestCity())), 'country_id' => $request->getDestCountryId(), 'postcode' => $request->getDestPostcode());
$quoteId = Mage::getSingleton('checkout/session')->getQuoteId();
$quote = Mage::getModel("sales/quote")->load($quoteId);
$result = Mage::getModel('aramexshipping/shipping')->getRatesAndPackages($quote, true, $destinationData);
$error = $result['error'];
$error_msg = isset($result['error_msg']) ? 'Aramex Error: ' . $result['error_msg'] : '';
$price = $result['price'];
$methodTitle = $request->getFreeShipping() ? Mage::helper('aramexshipping')->__('Free shipping applied') : '';
$handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
$result = Mage::getModel('shipping/rate_result');
if (!$error && $price > 0 || !$error && $request->getFreeShipping()) {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setMethod($this->_code);
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethodTitle($methodTitle);
$method->setPrice($price);
$method->setCost($price);
$result->append($method);
} else {
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$error->setErrorMessage($error_msg ? $error_msg : $this->getConfigData('specificerrmsg'));
$result->append($error);
if ($error_msg) {
Mage::helper('aramexshipping')->log($error_msg, '', 'aramex_collect_rates');
Mage::helper('aramexshipping')->sendLogEmail(array('subject' => 'Collect Rates Error Log', 'content' => $error_msg));
}
}
return $result;
}
示例14: getRate
/**
* Fetch rate from the table for selected shipping address.
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return array
*/
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
$adapter = $this->_getReadAdapter();
$bind = array(':website_id' => (int) $request->getWebsiteId(), ':country_id' => $request->getDestCountryId(), ':region_id' => (int) $request->getDestRegionId(), ':postcode' => $request->getDestPostcode());
$select = $adapter->select()->from($this->getMainTable())->where('website_id = :website_id')->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))->limit(1);
// Render destination condition
$orWhere = '(' . implode(') OR (', array("dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'", "dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'", "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'")) . ')';
$select->where($orWhere);
// Render condition by condition name
if (is_array($request->getConditionName())) {
$orWhere = array();
$i = 0;
foreach ($request->getConditionName() as $conditionName) {
$bindNameKey = sprintf(':condition_name_%d', $i);
$bindValueKey = sprintf(':condition_value_%d', $i);
$orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
$bind[$bindNameKey] = $conditionName;
$bind[$bindValueKey] = $request->getData($conditionName);
$i++;
}
if ($orWhere) {
$select->where(implode(' OR ', $orWhere));
}
} else {
$bind[':condition_name'] = $request->getConditionName();
$bind[':condition_value'] = $request->getData($request->getConditionName());
$select->where('condition_name = :condition_name');
$select->where('condition_value <= :condition_value');
}
$result = $adapter->fetchRow($select, $bind);
// Normalize destination zip code
if ($result && $result['dest_zip'] == '*') {
$result['dest_zip'] = '';
}
return $result;
}
示例15: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
$result = Mage::getModel('shipping/rate_result');
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$cepdest = $request->getDestPostcode();
$cepdest = str_replace('-', '', $cepdest);
$value = $request->getPackageValue();
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$collection = Mage::getModel('motoboyconfig/motoboyconfig')->getCollection();
$collection->addFieldToFilter('cepinicial', array('lteq' => $cepdest));
$collection->addFieldToFilter('cepfinal', array('gteq' => $cepdest));
$frete = $collection->getFirstItem();
if ($frete->getData('valor_pedido')) {
$valor = $frete->getData('valor_pedido');
$prazo = $frete->getData('prazo');
$method->setMethodTitle($this->getConfigData('name') . ' - <font color="red"> ' . $prazo . ' dias para entrega </font>');
$method->setPrice($valor);
$method->setCost($valor);
$result->append($method);
}
return $result;
}