本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request::getBaseCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request::getBaseCurrency方法的具体用法?PHP Mage_Shipping_Model_Rate_Request::getBaseCurrency怎么用?PHP Mage_Shipping_Model_Rate_Request::getBaseCurrency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Shipping_Model_Rate_Request
的用法示例。
在下文中一共展示了Mage_Shipping_Model_Rate_Request::getBaseCurrency方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: collectRates
/**
* Enter description here...
*
* @param Mage_Shipping_Model_Rate_Request $data
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
$result = Mage::getModel('shipping/rate_result');
$packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
$allow = $request->getFreeShipping() || $packageValue >= $this->getConfigData('cutoff_cost');
if ($allow) {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier('freeshipping');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('freeshipping');
$method->setMethodTitle($this->getConfigData('name'));
$method->setPrice('0.00');
$method->setCost('0.00');
$result->append($method);
}
return $result;
}
示例3: collectRates
/**
* Enter description here...
*
* @param Mage_Shipping_Model_Rate_Request $data
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
$allow = $request->getmultiflat();
$result = Mage::getModel('shipping/rate_result');
$packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
for ($i = 0; $i <= 10; $i++) {
if ($this->getConfigData('type' . $i) == 'O') {
// per order
$shippingPrice = $this->getConfigData('price' . $i);
} elseif ($this->getConfigData('type' . $i) == 'I') {
// per item
$shippingPrice = $request->getPackageQty() * $this->getConfigData('price' . $i) - $this->getFreeBoxes() * $this->getConfigData('price' . $i);
} else {
$shippingPrice = $this->getConfigData('price' . $i);
}
$shippingName = $this->getConfigData('name' . $i);
if ($shippingName != "" && ($packageValue >= $this->getConfigData('min_shipping' . $i) && $packageValue <= $this->getConfigData('max_shipping' . $i)) or $shippingName != "" && $this->getConfigData('max_shipping' . $i) == "") {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier('msmultiflat');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod($this->getConfigData('name' . $i));
$method->setMethodTitle($this->getConfigData('name' . $i));
$method->setMethodDetails($this->getConfigData('details' . $i));
$method->setMethodDescription($this->getConfigData('details' . $i));
$method->setPrice($shippingPrice);
$method->setCost($shippingPrice);
$result->append($method);
} else {
if ($shippingName == "") {
}
}
}
return $result;
}
示例4: _inicialCheck
/**
* Make initial checks and iniciate module variables
*
* @param Mage_Shipping_Model_Rate_Request $request Mage request
*
* @return bool
*/
protected function _inicialCheck(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
// Disabled
Mage::log('pedroteixeira_correios: Disabled');
return false;
}
$origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
$destCountry = $request->getDestCountryId();
if ($origCountry != 'BR' || $destCountry != 'BR') {
// Out of delivery area
Mage::log('pedroteixeira_correios: Out of delivery area');
return false;
}
$this->_fromZip = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$this->_toZip = $request->getDestPostcode();
// Fix ZIP code
$this->_fromZip = str_replace(array('-', '.'), '', trim($this->_fromZip));
$this->_toZip = str_replace(array('-', '.'), '', trim($this->_toZip));
if (!preg_match('/^([0-9]{8})$/', $this->_fromZip)) {
Mage::log('pedroteixeira_correios: From ZIP Code Error');
return false;
}
$this->_result = Mage::getModel('shipping/rate_result');
$this->_packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
$this->_packageWeight = number_format($request->getPackageWeight(), 2, '.', '');
$this->_freeMethodWeight = number_format($request->getFreeMethodWeight(), 2, '.', '');
}
示例5: _inicialCheck
/**
* Make initial checks and iniciate module variables
*
* @param Mage_Shipping_Model_Rate_Request $request Mage request
*
* @return bool
*/
protected function _inicialCheck(Mage_Shipping_Model_Rate_Request $request)
{
$this->_prepareProductsToSendFastShipping();
$this->_fromZip = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$this->_toZip = $request->getDestPostcode();
// Fix ZIP code
$this->_fromZip = str_replace(array('-', '.'), '', trim($this->_fromZip));
$this->_toZip = str_replace(array('-', '.'), '', trim($this->_toZip));
$this->_result = Mage::getModel('shipping/rate_result');
$this->_packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
$this->_packageWeight = number_format($request->getPackageWeight(), 2, '.', '');
$this->_freeMethodWeight = number_format($request->getFreeMethodWeight(), 2, '.', '');
}
示例6: _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;
}
示例7: _inicialCheck
/**
* Make initial checks and iniciate module variables
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return boolean
*/
protected function _inicialCheck(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
//Disabled
Mage::log('O2TI_Sisfrete: Disabled');
return false;
}
$origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
$destCountry = $request->getDestCountryId();
if ($origCountry != "BR" || $destCountry != "BR") {
//Out of delivery area
Mage::log('O2TI_Sisfrete: Out of delivery area');
return false;
}
// ZIP Code
$this->_fromZip = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$this->_toZip = $request->getDestPostcode();
//Fix Zip Code
$this->_fromZip = str_replace(array('-', '.'), '', trim($this->_fromZip));
$this->_toZip = str_replace(array('-', '.'), '', trim($this->_toZip));
if (!preg_match("/^([0-9]{8})\$/", $this->_fromZip)) {
//From zip code error
Mage::log('O2TI_Sisfrete: From ZIP Code Error');
return false;
}
// Result model
$this->_result = Mage::getModel('shipping/rate_result');
// Value
$this->_packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
// Weight
$this->_packageWeight = number_format($request->getPackageWeight(), 2, '.', '');
// Free method weight
$this->_freeMethodWeight = number_format($request->getFreeMethodWeight(), 2, '.', '');
}
示例8: collectRates
/**
* Collect Rates
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
//Disabled
return false;
}
$origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
$destCountry = $request->getDestCountryId();
if ($origCountry != "BR" || $destCountry != "BR") {
//Out of delivery area
return false;
}
// Generate Volume Weight
if ($this->_generateVolumeWeight() === false) {
// Dimension error
$this->_throwError('dimensionerror', 'Dimension error', __LINE__);
return $this->_result;
}
$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());
$minorderval = $this->getConfigData('min_order_value');
$maxorderval = $this->getConfigData('max_order_value');
if ($packagevalue <= $minorderval || $packagevalue >= $maxorderval) {
//Value limits
$error->setErrorMessage($this->getConfigData('valueerror'));
$result->append($error);
return $result;
}
$frompcode = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$topcode = $request->getDestPostcode();
//Fix Zip Code
$frompcode = str_replace('-', '', trim($frompcode));
$topcode = str_replace('-', '', trim($topcode));
if (!preg_match("/^([0-9]{8})\$/", $topcode)) {
//Invalid Zip Code
$error->setErrorMessage($this->getConfigData('zipcodeerror'));
$result->append($error);
Mage::helper('customer')->__('Invalid ZIP CODE');
return $result;
}
$sweight = $request->getPackageWeight();
$valor = number_format($packagevalue, 2, ',', '');
$peso = number_format($sweight, 2, ',', '');
try {
$retorno = $this->CalcFreteJamef($this->getConfigData('cnpj'), $topcode, $valor, $peso, $this->_volumeWeight, $this->getConfigData('filial_jamef'), $this->getConfigData('uf_jamef'));
} catch (Exception $e) {
$error->setErrorMessage($this->getConfigData('urlerror'));
Mage::log($result->append($error));
return $result;
}
$err_msg = "OK";
if (trim($err_msg) == "OK") {
$shippingPrice = str_replace(',', '.', $retorno->frete->valor);
} else {
//Invalid Zip Code
$error->setErrorMessage($this->getConfigData('zipcodeerror'));
echo $result->append($error);
return $result;
}
if ($shippingPrice <= 0) {
//Invalid Zip Code
$error->setErrorMessage($this->getConfigData('zipcodeerror'));
$result->append($error);
Mage::helper('customer')->__('Invalid ZIP CODE');
return $result;
}
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setCarrierTitle($this->getConfigData('name'));
$method->setMethod('jamef');
// if ($this->getConfigFlag('prazo_entrega')){
// $method->setMethodTitle(sprintf($this->getConfigData('msgprazo'), '', $retorno->PRAZO ));
// }else{
// $method->setMethodTitle('Jamef');
// }
$method->setPrice($shippingPrice + $shippingPrice * ($this->getConfigData('handling_fee') / 100));
$method->setCost($shippingPrice);
$result->append($method);
$this->_result = $result;
// $this->_updateFreeMethodQuote($request);
return $this->_result;
}
示例9: collectRates
/**
* Collect rates for this shipping method based on information in $request
*
* @param Mage_Shipping_Model_Rate_Request $data
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
// skip if not enabled
if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
return false;
}
$result = Mage::getModel('shipping/rate_result');
$packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
$temp = array();
//get sheepla module config
$sConfig = Mage::getStoreConfig('sheepla');
//if user is using dynamic pricing
if ($sConfig['advanced']['use_dynamic_pricing']) {
//support admin and user checkout
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
//admin
$quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
} else {
//user
$quote = Mage::getSingleton('checkout/session')->getQuote();
}
$items = $quote->getAllVisibleItems();
$address = $quote->getShippingAddress();
try {
$this->initSheeplaObjects();
$dpRates = $this->sp->getClient()->getDynamicPricing($address, $items);
$availableDynamicTemplateIds = array();
foreach ($dpRates as $rate) {
$availableDynamicTemplateIds[] = $rate['shipmentTemplateId'];
}
} catch (Exception $e) {
$dpRates = false;
Mage::Log('[Sheepla][' . date('Y-m-d H:i:s') . ']' . $e->getMessage());
}
} else {
$dpRates = false;
}
for ($i = 1; $i <= 10; $i++) {
if ($this->getMethodConfig('allowspecific', $i)) {
$availableCountries = explode(',', $this->getMethodConfig('specificcountry', $i));
if (!($availableCountries && in_array($request->getDestCountryId(), $availableCountries))) {
continue;
}
}
$shippingName = $this->getMethodConfig('name', $i);
$shippingPrice = $this->getMethodConfig('price', $i);
if (!empty($shippingName)) {
//if dynamic pricing enabled and method is not at dpRates table, skip this method
if (is_array($dpRates)) {
$shippingTemplateId = $this->getMethodConfig('template_id', $i);
if ($shippingTemplateId != '0' && !in_array($shippingTemplateId, $availableDynamicTemplateIds)) {
continue;
}
}
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier('sheepla');
$method->setMethod('method_' . $i);
$method->setMethodTitle($this->getMethodConfig('name', $i));
$method->setMethodDetails($this->getMethodConfig('desc', $i));
$method->setMethodDescription($this->getMethodConfig('desc', $i));
$method->setPrice(preg_replace('/,/', '.', $shippingPrice));
$method->setCost($this->getMethodConfig('cost', $i));
if (isset($sConfig['advanced']['custom_label']) && !empty($sConfig['advanced']['custom_label'])) {
$method->setCarrierTitle($sConfig['advanced']['custom_label']);
} else {
$method->setCarrierTitle(Mage::helper('sheepla/data')->__('Robust delivery by Sheepla!'));
}
//dynamic price calculate
if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
$method->setPrice('0.00');
} elseif (is_array($dpRates)) {
foreach ($sConfig as $k => $v) {
if ($method->getMethod() == $k) {
foreach ($dpRates as $rule) {
if ($rule['shipmentTemplateId'] == $v['template_id']) {
$method->setPrice($rule['price']);
}
}
}
}
}
$temp[$this->getMethodConfig('sort_order', $i)] = $method;
}
}
foreach ($temp as $m) {
$result->append($m);
}
return $result;
}
示例10: _inicialCheck
/**
* Make initial checks and iniciate module variables
*
* @param Mage_Shipping_Model_Rate_Request $request Mage request
*
* @return bool
*/
protected function _inicialCheck(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
// Disabled
Mage::log('pedroteixeira_correios: Disabled');
return false;
}
$origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
$destCountry = $request->getDestCountryId();
if ($origCountry != 'BR' || $destCountry != 'BR') {
// Out of delivery area
Mage::log('pedroteixeira_correios: Out of delivery area');
return false;
}
$this->_fromZip = Mage::getStoreConfig('shipping/origin/postcode', $this->getStore());
$this->_toZip = $request->getDestPostcode();
// Fix ZIP code
$this->_fromZip = str_replace(array('-', '.'), '', trim($this->_fromZip));
$this->_toZip = str_replace(array('-', '.'), '', trim($this->_toZip));
if (!preg_match('/^([0-9]{8})$/', $this->_fromZip)) {
Mage::log('pedroteixeira_correios: From ZIP Code Error');
return false;
}
$this->_result = Mage::getModel('shipping/rate_result');
$this->_packageValue = $request->getBaseCurrency()->convert($request->getPackageValue(), $request->getPackageCurrency());
$this->_packageWeight = number_format($request->getPackageWeight(), 2, '.', '');
$this->_freeMethodWeight = number_format($request->getFreeMethodWeight(), 2, '.', '');
if ($this->_packageWeight <= 0) {
$this->_packageWeight = 0;
foreach ($request->getAllItems() as $item) {
$prod = Mage::getModel('catalog/product');
$prod->load($item->getProduct()->getId());
if ($prod->getTypeID() == 'configurable') {
$lastQty = $item->getQty();
$qtd = 0;
continue;
} else {
if ($lastQty > 0) {
$qtd = $lastQty;
$lastQty = 0;
}
}
$this->_packageWeight = $this->_packageWeight + $prod->getWeight() * $qtd;
}
}
}