本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request::getDestStreet方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request::getDestStreet方法的具体用法?PHP Mage_Shipping_Model_Rate_Request::getDestStreet怎么用?PHP Mage_Shipping_Model_Rate_Request::getDestStreet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Shipping_Model_Rate_Request
的用法示例。
在下文中一共展示了Mage_Shipping_Model_Rate_Request::getDestStreet方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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;
}
示例2: 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;
}
}
示例3: setRequest
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
$r->setStoreId($request->getStoreId());
if ($request->getLimitMethod()) {
$r->setService($request->getLimitMethod());
}
if ($request->getDhlId()) {
$id = $request->getDhlId();
} else {
$id = $this->getConfigData('id');
}
$r->setId($id);
if ($request->getDhlPassword()) {
$password = $request->getDhlPassword();
} else {
$password = $this->getConfigData('password');
}
$r->setPassword($password);
if ($request->getDhlAccount()) {
$accountNbr = $request->getDhlAccount();
} else {
$accountNbr = $this->getConfigData('account');
}
$r->setAccountNbr($accountNbr);
if ($request->getDhlShippingKey()) {
$shippingKey = $request->getDhlShippingKey();
} else {
$shippingKey = $this->getConfigData('shipping_key');
}
$r->setShippingKey($shippingKey);
if ($request->getDhlShippingIntlKey()) {
$shippingKey = $request->getDhlShippingIntlKey();
} else {
$shippingKey = $this->getConfigData('shipping_intlkey');
}
$r->setShippingIntlKey($shippingKey);
if ($request->getDhlShipmentType()) {
$shipmentType = $request->getDhlShipmentType();
} else {
$shipmentType = $this->getConfigData('shipment_type');
}
$r->setShipmentType($shipmentType);
if ($request->getDhlDutiable()) {
$shipmentDutible = $request->getDhlDutiable();
} else {
$shipmentDutible = $this->getConfigData('dutiable');
}
$r->setDutiable($shipmentDutible);
if ($request->getDhlDutyPaymentType()) {
$dutypaytype = $request->getDhlDutyPaymentType();
} else {
$dutypaytype = $this->getConfigData('dutypaymenttype');
}
$r->setDutyPaymentType($dutypaytype);
if ($request->getDhlContentDesc()) {
$contentdesc = $request->getDhlContentDesc();
} else {
$contentdesc = $this->getConfigData('contentdesc');
}
$r->setContentDesc($contentdesc);
if ($request->getDestPostcode()) {
$r->setDestPostal($request->getDestPostcode());
}
if ($request->getOrigCountry()) {
$origCountry = $request->getOrigCountry();
} else {
$origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
}
$r->setOrigCountry($origCountry);
/*
* DHL only accepts weight as a whole number. Maximum length is 3 digits.
*/
$weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
$shippingWeight = round(max(1, $weight), 0);
$r->setValue(round($request->getPackageValue(), 2));
$r->setValueWithDiscount($request->getPackageValueWithDiscount());
$r->setDestStreet(Mage::helper('core/string')->substr($request->getDestStreet(), 0, 35));
$r->setDestCity($request->getDestCity());
if ($request->getDestCountryId()) {
$destCountry = $request->getDestCountryId();
} else {
$destCountry = self::USA_COUNTRY_ID;
}
//for DHL, puero rico state for US will assume as puerto rico country
//for puerto rico, dhl will ship as international
if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID)) {
$destCountry = self::PUERTORICO_COUNTRY_ID;
}
$r->setDestCountryId($destCountry);
$r->setDestState($request->getDestRegionCode());
$r->setWeight($shippingWeight);
$r->setFreeMethodWeight($request->getFreeMethodWeight());
$this->_rawRequest = $r;
// $methods = explode(',', $this->getConfigData('allowed_methods'));
//
// $freeMethod = $this->getConfigData('free_method');
//
// $internationcode = $this->getCode('international_searvice');
//.........这里部分代码省略.........
示例4: process
public function process(Mage_Shipping_Model_Rate_Request $request)
{
$this->_request = $request;
$r = new Varien_Object();
if ($request->getLimitMethod()) {
$r->setService($request->getLimitMethod());
}
if ($request->getDhlId()) {
$id = $request->getDhlId();
} else {
$id = $this->getConfigData('id');
}
$r->setId($id);
if ($request->getDhlPassword()) {
$password = $request->getDhlPassword();
} else {
$password = $this->getConfigData('password');
}
$r->setPassword($password);
if ($request->getDhlAccount()) {
$accountNbr = $request->getDhlAccount();
} else {
$accountNbr = $this->getConfigData('account');
}
$r->setAccountNbr($accountNbr);
if ($request->getDhlShippingKey()) {
$shippingKey = $request->getDhlShippingKey();
} else {
$shippingKey = $this->getConfigData('shipping_key');
}
$r->setShippingKey($shippingKey);
if ($request->getDhlShippingIntlKey()) {
$shippingKey = $request->getDhlShippingIntlKey();
} else {
$shippingKey = $this->getConfigData('shipping_intlkey');
}
$r->setShippingIntlKey($shippingKey);
if ($request->getDhlShipmentType()) {
$shipmentType = $request->getDhlShipmentType();
} else {
$shipmentType = $this->getConfigData('shipment_type');
}
$r->setShipmentType($shipmentType);
if ($request->getDhlDutiable()) {
$shipmentDutible = $request->getDhlDutiable();
} else {
$shipmentDutible = $this->getConfigData('dutiable');
}
$r->setDutiable($shipmentDutible);
if ($request->getDhlDutyPaymentType()) {
$dutypaytype = $request->getDhlDutyPaymentType();
} else {
$dutypaytype = $this->getConfigData('dutypaymenttype');
}
$r->setDutyPaymentType($dutypaytype);
if ($request->getDhlContentDesc()) {
$contentdesc = $request->getDhlContentDesc();
} else {
$contentdesc = $this->getConfigData('contentdesc');
}
$r->setContentDesc($contentdesc);
if ($request->getDestPostcode()) {
$r->setDestPostal($request->getDestPostcode());
}
if ($request->getOrigCountry()) {
$origCountry = $request->getOrigCountry();
} else {
$origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
}
$r->setOrigCountry($origCountry);
/*
* DHL only accepts weight as a whole number. Maximum length is 3 digits.
*/
$shippingWeight = round(min(1, $request->getPackageWeight()), 0);
$freeMethodWeight = round(min(1, $request->getFreeMethodWeight()), 0);
$r->setValue(round($request->getPackageValue(), 2));
$r->setDestStreet(substr($request->getDestStreet(), 0, 35));
$r->setDestCity($request->getDestCity());
$r->setDestCountryId($request->getDestCountryId());
$r->setDestState($request->getDestRegionCode());
$this->_rawRequest = $r;
$methods = explode(',', $this->getConfigData('allowed_methods'));
$freeMethod = $this->getConfigData('free_method');
$internationcode = $this->getCode('international_searvice');
foreach ($methods as $method) {
if ($method == $internationcode && $r->getDestCountryId() != self::USA_COUNTRY_ID || $method != $internationcode && $r->getDestCountryId() == self::USA_COUNTRY_ID) {
$weight = $freeMethod == $method ? $freeMethodWeight : $shippingWeight;
if ($weight > 0) {
$this->_rawRequest->setWeight($weight);
$this->_rawRequest->setService($method);
$this->_getQuotes();
} else {
$this->_dhlRates[$method] = array('term' => $this->getCode('service', $method), 'price_total' => 0);
}
}
}
return $this;
}
示例5: _submitRequest
/**
* @param Mage_Shipping_Model_Rate_Request $requestVar
* @return array
*/
private function _submitRequest(Mage_Shipping_Model_Rate_Request $requestVar)
{
$shipwireAvailableServices = $this->getConfigData('availableservices');
$shipwireUsername = $this->getConfigData('shipwire_email');
$shipwirePassword = $this->getConfigData('shipwire_password');
$orderCurrencyCode = 'USD';
/**
* @var $orderCurrency Mage_Directory_Model_Currency
*/
$orderCurrency = $requestVar->getBaseCurrency();
if (!empty($orderCurrency)) {
$orderCurrencyCode = $orderCurrency->getCode();
}
$orderNumber = uniqid('magento', TRUE);
$shipToAddress1 = $requestVar->getDestStreet();
$shipToCity = $requestVar->getDestCity();
$shipToRegion = $requestVar->getDestRegionCode();
$shipToCountry = $requestVar->getDestCountryId();
$shiptoPostalCode = $requestVar->getDestPostcode();
$requestItems = $requestVar->getAllItems();
$itemXml = $this->_buildRequestItemXml($requestItems);
$rateRequestXml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE RateRequest SYSTEM "http://www.shipwire.com/exec/download/RateRequest.dtd">
<RateRequest currency="{$orderCurrencyCode}">
<Username><![CDATA[{$shipwireUsername}]]></Username>
<Password><![CDATA[{$shipwirePassword}]]></Password>
<Source>{$this->_version}</Source>
<Order id="{$orderNumber}">
<AddressInfo type="ship">
<Address1><![CDATA[{$shipToAddress1}]]></Address1>
<City><![CDATA[{$shipToCity}]]></City>
<State><![CDATA[{$shipToRegion}]]></State>
<Country><![CDATA[{$shipToCountry}]]></Country>
<Zip><![CDATA[{$shiptoPostalCode}]]></Zip>
</AddressInfo>
{$itemXml}
</Order>
</RateRequest>
XML;
$curlSession = curl_init();
curl_setopt($curlSession, CURLOPT_URL, $this->_apiEndpoint);
curl_setopt($curlSession, CURLOPT_POST, true);
curl_setopt($curlSession, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
curl_setopt($curlSession, CURLOPT_POSTFIELDS, $rateRequestXml);
curl_setopt($curlSession, CURLOPT_HEADER, false);
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlSession, CURLOPT_TIMEOUT, 60);
$response = curl_exec($curlSession);
$emptyRateResult = array();
if (FALSE === $response) {
return $emptyRateResult;
}
$parser = xml_parser_create();
xml_parse_into_struct($parser, $response, $xmlVals, $xmlIndex);
xml_parser_free($parser);
foreach ($xmlVals as $key) {
if ($key['tag'] == 'STATUS') {
if ($key['value'] != 'OK') {
return $emptyRateResult;
}
}
}
$code = array();
$method = array();
$cost = array();
$supportedServices = explode(',', $shipwireAvailableServices);
foreach ($xmlVals as $key) {
if ($key['tag'] == 'QUOTE' && $key['type'] == 'open' && $key['level'] == 4) {
$code[] = $key['attributes']['METHOD'];
}
if ($key['tag'] == 'SERVICE' && $key['type'] == 'complete' && $key['level'] == 5) {
$method[] = $key['value'];
}
if ($key['tag'] == 'COST' && $key['type'] == 'complete' && $key['level'] == 5) {
$cost[] = $key['value'];
}
}
$la = count($code);
$lb = count($method);
$lc = count($cost);
$rateResult = array();
if ($la == $lb && $lb == $lc) {
foreach ($code as $index => $value) {
if (in_array($value, $supportedServices)) {
$rateResult[] = array('code' => $code[$index], 'title' => $method[$index], 'amount' => $cost[$index]);
}
}
}
return $rateResult;
}
示例6: _getProductionShipmentFields
private function _getProductionShipmentFields(Mage_Shipping_Model_Rate_Request $mgrequest)
{
$regionId = $mgrequest->getRegionId();
$region = Mage::getModel('directory/region')->load($regionId);
$request->Shipment->SenderInformation->Address->Name = "Aaron Summer";
//$request->Shipment->SenderInformation->Address->StreetNumber = "1234";
$request->Shipment->SenderInformation->Address->StreetName = $mgrequest->getStreet();
$request->Shipment->SenderInformation->Address->City = $mgrequest->getCity();
$request->Shipment->SenderInformation->Address->Province = $region->getCode();
$request->Shipment->SenderInformation->Address->Country = $mgrequest->getCountryId();
$request->Shipment->SenderInformation->Address->PostalCode = $mgrequest->getPostcode();
$request->Shipment->SenderInformation->Address->PhoneNumber->CountryCode = "1";
$request->Shipment->SenderInformation->Address->PhoneNumber->AreaCode = "905";
$request->Shipment->SenderInformation->Address->PhoneNumber->Phone = substr("123456789", -7);
//Populate the Desination Information
$request->Shipment->ReceiverInformation->Address->Name = "Aaron Summer";
$request->Shipment->ReceiverInformation->Address->StreetName = $mgrequest->getDestStreet();
$request->Shipment->ReceiverInformation->Address->City = $mgrequest->getDestCity();
$regionId = $mgrequest->getDestRegionId();
$region = Mage::getModel('directory/region')->load($regionId);
$request->Shipment->ReceiverInformation->Address->Province = $region->getCode();
$request->Shipment->ReceiverInformation->Address->Country = $mgrequest->getDestCountryId();
$request->Shipment->ReceiverInformation->Address->PostalCode = $mgrequest->getDestPostcode();
$request->Shipment->ReceiverInformation->Address->PhoneNumber->CountryCode = "1";
$request->Shipment->ReceiverInformation->Address->PhoneNumber->AreaCode = "604";
$request->Shipment->ReceiverInformation->Address->PhoneNumber->Phone = substr("123456789", -7);
//Future Dated Shipments - YYYY-MM-DD format
$request->Shipment->ShipmentDate = Mage::getModel('core/date')->date('Y-m-d');
//Populate the Package Information
$request->Shipment->PackageInformation->TotalWeight->Value = $mgrequest->getPackageWeight();
$request->Shipment->PackageInformation->TotalWeight->WeightUnit = "lb";
$request->Shipment->PackageInformation->TotalPieces = $mgrequest->getPackageQty();
$request->Shipment->PackageInformation->ServiceID = "PurolatorExpress";
//Populate the Payment Information
$request->Shipment->PaymentInformation->PaymentType = "Sender";
$request->Shipment->PaymentInformation->BillingAccountNumber = $this->BILLING_ACCOUNT;
$request->Shipment->PaymentInformation->RegisteredAccountNumber = $this->REGISTERED_ACCOUNT;
//Populate the Pickup Information
$request->Shipment->PickupInformation->PickupType = "DropOff";
$request->ShowAlternativeServicesIndicator = "true";
//OriginSignatureNotRequired
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->ID = "OriginSignatureNotRequired";
$request->Shipment->PackageInformation->OptionsInformation->Options->OptionIDValuePair->Value = "true";
return $request;
}
示例7: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
try {
$helper = Mage::helper('localexpress_shipping');
$fields = $helper->getFields();
// skip if not processable
if (!$helper->isProcessable()) {
return false;
}
// return
$result = Mage::getModel('shipping/rate_result');
$human_id = Mage::getSingleton('checkout/session')->getData('localexpress_shipping_human_id');
// collect order information
$quote = Mage::getSingleton('checkout/session')->getQuote();
$firstname = $quote->getShippingAddress()->getFirstname();
$lastname = $quote->getShippingAddress()->getLastname();
$address = $request->getDestStreet();
$city = $request->getDestCity();
$zip = $request->getDestPostcode();
$country_iso639_2 = $request->getDestCountryId();
$country = Mage::getModel('directory/country')->loadByCode($country_iso639_2);
$country_name = $country->getName();
$store_currency = Mage::app()->getStore()->getCurrentCurrencyCode();
// get order totals
$order_info = Localexpress_Shipping_Helper_Data::getOrderTotals($request, Localexpress_Shipping_Helper_Data::catageryOnly(), Localexpress_Shipping_Helper_Data::attributesOnly());
if ($order_info['notPossible']) {
return false;
}
// addresses
$addr_origin = Localexpress_Shipping_Helper_Data::getAddressOrigin();
$addr_dest = Localexpress_Shipping_Helper_Data::buildAddress($country_iso639_2, $country_name, $address, $zip, $firstname . " " . $lastname, $city);
//TODO: demension attribute!!
$dimensions = Localexpress_Shipping_Helper_Data::buildDimensions(1, 1, 1);
// request quote
$available = $helper->shipmentAvailable($country_iso639_2, $address, $zip);
if (!$available) {
return false;
}
$quote = $helper->shipmentQuote($order_info["qty"], $order_info["weight"], $order_info["price"], $store_currency, $dimensions, $addr_origin, $addr_dest, "Quote request!", false, $human_id);
// invalid server response
if ($quote["info"]["http_code"] != 201 && $quote["info"]["http_code"] != 200) {
return false;
}
// list details
$human_id = Mage::getSingleton('checkout/session')->setData('localexpress_shipping_human_id', $quote['body']->shipment_quote->human_id);
$carrier_name = $fields["title"];
$service_name = $fields["service_name"];
$service_id = "1";
$service_price = $quote["body"]->shipment_quote->price;
// build response
$method = Mage::getModel('shipping/rate_result_method');
// carrier
$method->setCarrier(Localexpress_Shipping_Helper_Data::NAME);
$method->setCarrierTitle($fields['title'] . " (" . $carrier_name . ")");
// methods
$method->setMethod(Localexpress_Shipping_Helper_Data::SERVICE_NAME . '_' . $service_id);
$method->setMethodTitle($service_name);
$method->setPrice($service_price);
$method->setCost($service_price);
$result->append($method);
return $result;
} catch (\Exception $e) {
Localexpress_Shipping_Helper_Data::log($e->getMessage());
Localexpress_Shipping_Helper_Data::log($e->getTraceAsString());
// halt order checkout on error
die;
return false;
}
}