本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request类的具体用法?PHP Mage_Shipping_Model_Rate_Request怎么用?PHP Mage_Shipping_Model_Rate_Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Shipping_Model_Rate_Request类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: proccessAdditionalValidation
/**
* Processing additional validation to check is carrier applicable.
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean
*/
public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request)
{
//Skip by item validation if there is no items in request
if (!count($request->getAllItems())) {
return $this;
}
$maxAllowedWeight = (double) $this->getConfigData('max_package_weight');
$error = null;
$showMethod = $this->getConfigData('showmethod');
foreach ($request->getAllItems() as $item) {
if ($item->getProduct() && $item->getProduct()->getId()) {
if ($item->getProduct()->getWeight() > $maxAllowedWeight) {
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code)->setCarrierTitle($this->getConfigData('title'));
$errorMsg = $this->getConfigData('specificerrmsg');
$error->setErrorMessage($errorMsg ? $errorMsg : Mage::helper('shipping')->__('The shipping module is not available.'));
break;
}
}
}
if (null !== $error && $showMethod) {
return $error;
} elseif (null !== $error) {
return false;
}
return $this;
}
开发者ID:joebushi,项目名称:magento-mirror,代码行数:33,代码来源:Abstract.php
示例2: collectRates
/**
* Retrieve all methods for supplied shipping data
*
* @todo make it ordered
* @param Mage_Shipping_Model_Shipping_Method_Request $data
* @return Mage_Shipping_Model_Shipping
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
$storeId = $request->getStoreId();
if (!$request->getOrig()) {
$request->setCountryId(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_COUNTRY_ID, $storeId))->setRegionId(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_REGION_ID, $storeId))->setCity(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_CITY, $storeId))->setPostcode(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_POSTCODE, $storeId));
}
$limitCarrier = $request->getLimitCarrier();
if (!$limitCarrier) {
$carriers = Mage::getStoreConfig('carriers', $storeId);
foreach ($carriers as $carrierCode => $carrierConfig) {
$this->collectCarrierRates($carrierCode, $request);
}
} else {
if (!is_array($limitCarrier)) {
$limitCarrier = array($limitCarrier);
}
foreach ($limitCarrier as $carrierCode) {
$carrierConfig = Mage::getStoreConfig('carriers/' . $carrierCode, $storeId);
if (!$carrierConfig) {
continue;
}
$this->collectCarrierRates($carrierCode, $request);
}
}
return $this;
}
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:33,代码来源:Shipping.php
示例3: collectRates
/**
* FreeShipping Rates Collector
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
$ischeck = Mage::getStoreConfig('giftwrap/general/add_product_price');
if ($ischeck) {
$giftwrapAmount = Mage::helper('giftwrap')->giftwrapAmount();
} else {
$giftwrapAmount = 0;
}
if (!$this->getConfigFlag('active')) {
return false;
}
$result = Mage::getModel('shipping/rate_result');
// $packageValue = $request->getBaseCurrency()->convert($request->getPackageValueWithDiscount(), $request->getPackageCurrency());
$packageValue = $request->getPackageValueWithDiscount();
$this->_updateFreeMethodQuote($request);
$allow = $request->getFreeShipping() || $packageValue + $giftwrapAmount >= $this->getConfigData('free_shipping_subtotal');
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;
}
开发者ID:AleksNesh,项目名称:pandora,代码行数:34,代码来源:Freeshipping.php
示例4: collectRates
/**
* Retrieve all methods for supplied shipping data
*
* @todo make it ordered
* @param Mage_Shipping_Model_Shipping_Method_Request $data
* @return Mage_Shipping_Model_Shipping
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$request->getOrig()) {
$request->setCountryId(Mage::getStoreConfig('shipping/origin/country_id', $request->getStore()))->setRegionId(Mage::getStoreConfig('shipping/origin/region_id', $request->getStore()))->setCity(Mage::getStoreConfig('shipping/origin/city', $request->getStore()))->setPostcode(Mage::getStoreConfig('shipping/origin/postcode', $request->getStore()));
}
$limitCarrier = $request->getLimitCarrier();
if (!$limitCarrier) {
$carriers = Mage::getStoreConfig('carriers', $request->getStoreId());
foreach ($carriers as $carrierCode => $carrierConfig) {
$this->collectCarrierRates($carrierCode, $request);
}
} else {
if (!is_array($limitCarrier)) {
$limitCarrier = array($limitCarrier);
}
foreach ($limitCarrier as $carrierCode) {
$carrierConfig = Mage::getStoreConfig('carriers/' . $carrierCode, $request->getStoreId());
if (!$carrierConfig) {
continue;
}
$this->collectCarrierRates($carrierCode, $request);
}
}
return $this;
}
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:32,代码来源:Shipping.php
示例5: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
$result = Mage::getModel('shipping/rate_result');
/* @var $result Mage_Shipping_Model_Rate_Result */
$result->append($this->_getStandardShippingRate());
$expressWeightThreshold = $this->getConfigData('express_weight_threshold');
$eligibleForExpressDelivery = true;
foreach ($request->getAllItems() as $_item) {
if ($_item->getWeight() > $expressWeightThreshold) {
$eligibleForExpressDelivery = false;
}
}
if ($eligibleForExpressDelivery) {
$result->append($this->_getExpressShippingRate());
}
if ($request->getFreeShipping()) {
/**
* If the request has the free shipping flag,
* append a free shipping rate to the result.
*/
$freeShippingRate = $this->_getFreeShippingRate();
$result->append($freeShippingRate);
}
return $result;
}
开发者ID:juliasagayda,项目名称:magento,代码行数:25,代码来源:Carrier.php
示例6: 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');
if ($this->getConfigData('type') == 'O') {
// per order
$shippingPrice = $this->getConfigData('price');
} elseif ($this->getConfigData('type') == 'I') {
// per item
$shippingPrice = $request->getPackageQty() * $this->getConfigData('price');
} else {
$shippingPrice = false;
}
$shippingPrice += $this->getConfigData('handling_fee');
if ($shippingPrice) {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier('flatrate');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('flatrate');
$method->setMethodTitle($this->getConfigData('name'));
$method->setPrice($shippingPrice);
$method->setCost($shippingPrice);
$result->append($method);
}
return $result;
}
开发者ID:arslbbt,项目名称:mangentovies,代码行数:34,代码来源:Flatrate.php
示例7: 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;
}
开发者ID:rob3000,项目名称:fontis_australia,代码行数:41,代码来源:Australiapost.php
示例8: 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)
{
if (!$this->getConfigData('active')) {
return false;
}
$result = Mage::getModel('shipping/rate_result');
$collection = Mage::getResourceModel('amtable/method_collection')->addFieldToFilter('is_active', 1)->addStoreFilter($request->getStoreId())->addCustomerGroupFilter($this->getCustomerGroupId($request))->setOrder('pos');
$rates = Mage::getModel('amtable/rate')->findBy($request, $collection);
foreach ($collection as $customMethod) {
// create new instance of method rate
$method = Mage::getModel('shipping/rate_result_method');
// record carrier information
$method->setCarrier($this->_code);
$method->setCarrierTitle($this->getConfigData('title'));
// record method information
$method->setMethod($this->_code . $customMethod->getId());
$method->setMethodTitle(Mage::helper('amtable')->__($customMethod->getName()));
if (isset($rates[$customMethod->getId()])) {
$method->setCost($rates[$customMethod->getId()]);
$method->setPrice($rates[$customMethod->getId()]);
// add this rate to the result
$result->append($method);
}
}
return $result;
}
开发者ID:AleksNesh,项目名称:pandora,代码行数:32,代码来源:Table.php
示例9: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
$shippingPrice = 0;
if ($request->getAllItems()) {
foreach ($request->getAllItems() as $item) {
$product = Mage::getModel('catalog/product')->load($item->getProductId());
if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'bundle') {
continue;
}
$shipCost = $product->getShipCost();
if ($shipCost == null || $shipCost == 0) {
$shippingPrice += $item->getQty() * $this->getConfigData('price');
} else {
$shippingPrice += $item->getQty() * $shipCost;
}
}
}
$result = Mage::getModel('shipping/rate_result');
if ($shippingPrice !== false) {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier('flatrateperproduct');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('flatrateperproduct');
$method->setMethodTitle($this->getConfigData('name'));
$method->setPrice($shippingPrice);
$method->setCost($shippingPrice);
$result->append($method);
}
return $result;
}
开发者ID:lynxtdc,项目名称:aromaworks,代码行数:33,代码来源:Flatrateperproduct.php
示例10: 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;
}
开发者ID:Hospeed,项目名称:gamuza_freight-magento,代码行数:27,代码来源:Abstract.php
示例11: checkAvailableShipCountries
public function checkAvailableShipCountries(Mage_Shipping_Model_Rate_Request $request)
{
$speCountriesAllow = $this->getConfigData('sallowspecific');
/*
* for specific countries, the flag will be 1
*/
if ($speCountriesAllow && $speCountriesAllow == 1) {
$showMethod = $this->getConfigData('showmethod');
$availableCountries = array();
if ($this->getConfigData('specificcountry')) {
$availableCountries = explode(',', $this->getConfigData('specificcountry'));
}
if ($availableCountries && in_array($request->getDestCountryId(), $availableCountries)) {
return $this;
} elseif ($showMethod && (!$availableCountries || $availableCountries && !in_array($request->getDestCountryId(), $availableCountries))) {
$error = Mage::getModel('shipping/rate_result_error');
$error->setCarrier($this->_code);
$error->setCarrierTitle($this->getConfigData('title'));
$errorMsg = $this->getConfigData('specificerrmsg');
$error->setErrorMessage($errorMsg ? $errorMsg : Mage::helper('shipping')->__('The shipping module is not available for selected delivery country.'));
return $error;
} else {
/*
* The admin set not to show the shipping module if the devliery country is not within specific countries
*/
return false;
}
}
return $this;
}
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:30,代码来源:Abstract.php
示例12: collectRates
/**
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Rate_Result
*/
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
/** @var Mage_Shipping_Model_Rate_Result $result */
$result = Mage::getModel('shipping/rate_result');
$totalWeight = 0;
foreach ($request->getAllItems() as $item) {
$totalWeight += $item->getWeight() * $item->getQty();
}
/** @var string $hostname */
$hostname = $this->getConfigData('hostname');
/** @var string $port */
$port = $this->getConfigData('port');
try {
$client = new Zend_Http_Client();
$response = $client->setUri("http://{$hostname}:{$port}/")->setRawData(json_encode(['totalWeight' => $totalWeight]))->setEncType('application/json')->request('POST');
switch ($response->getStatus()) {
case 200:
$responseBody = json_decode($response->getBody());
$result->append($this->_getShippingMethod($responseBody->rate));
break;
case 500:
// Handle 500 Error
break;
default:
}
} catch (Exception $e) {
var_dump($e);
}
return $result;
}
开发者ID:sraleci,项目名称:ba-shipping-method,代码行数:34,代码来源:Carrier.php
示例13: proccessAdditionalValidation
/**
* Processing additional validation to check is carrier applicable.
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean
*/
public function proccessAdditionalValidation(Mage_Shipping_Model_Rate_Request $request)
{
//Skip by item validation if there is no items in request
if (!count($request->getAllItems())) {
return $this;
}
$maxAllowedWeight = (double) $this->getConfigData('max_package_weight');
$errorMsg = '';
$configErrorMsg = $this->getConfigData('specificerrmsg');
$defaultErrorMsg = Mage::helper('shipping')->__('The shipping module is not available.');
$showMethod = $this->getConfigData('showmethod');
foreach ($request->getAllItems() as $item) {
if ($item->getProduct() && $item->getProduct()->getId()) {
if ($item->getProduct()->getWeight() > $maxAllowedWeight) {
$errorMsg = $configErrorMsg ? $configErrorMsg : $defaultErrorMsg;
break;
}
}
}
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;
}
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:39,代码来源:Abstract.php
示例14: setRequest
/**
* Prepare and set request to this instance
*
* @param Mage_Shipping_Model_Rate_Request $request
* @return Mage_Usa_Model_Shipping_Carrier_Ups
*/
public function setRequest(Mage_Shipping_Model_Rate_Request $request)
{
$quote = $request->getQuote();
if (!$quote || !$quote->getId()) {
$quote = Mage::getSingleton('checkout/session')->getQuote();
}
if (!$quote || !$quote->getId() && Mage::registry('recurring_order', false)) {
$quote = Mage::registry('recurring_order')->getQuote();
}
if ($quote && $quote->getId()) {
Mage::unregister('recurring_quote');
Mage::register('recurring_quote', $quote);
}
parent::setRequest($request);
if (!$quote || !$quote->getId()) {
return $this;
}
// last attempt at checking this damn thing
if (!$quote->getShippingAddress()->getResidentialIndicator()) {
Mage::dispatchEvent('widgetized_validate_address', array($this->_eventObject => $this, 'order' => $quote));
}
// Manually overriding the residential indicator
if ($indicator = $quote->getShippingAddress()->getResidentialIndicator()) {
$this->_rawRequest->setDestType($indicator);
}
return $this;
}
开发者ID:Jonathonbyrd,项目名称:Optimized-Magento-1.9.x,代码行数:33,代码来源:Ups.php
示例15: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
$result = Mage::getModel('shipping/rate_result');
foreach ($request->getAllItems() as $item) {
}
$result->append($this->_getStandardRate());
return $result;
}
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:8,代码来源:Webposshipping.php
示例16: _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;
}
开发者ID:qwintry,项目名称:logistics-magento,代码行数:28,代码来源:Carrier.php
示例17: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
if (!$request->getConditionName()) {
$request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
}
$result = Mage::getModel('shipping/rate_result');
$rates = $this->getRate($request);
if (is_array($rates)) {
foreach ($rates as $rate) {
if (!empty($rate) && $rate['price'] >= 0) {
/** @var Mage_Shipping_Model_Rate_Result_Method $method */
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier('eparcel');
$method->setCarrierTitle($this->getConfigData('title'));
if ($this->_getChargeCode($rate)) {
$_method = strtolower(str_replace(' ', '_', $this->_getChargeCode($rate)));
} else {
$_method = strtolower(str_replace(' ', '_', $rate['delivery_type']));
}
$method->setMethod($_method);
if ($this->getConfigData('carriers/eparcel/name')) {
$method->setMethodTitle($this->getConfigData('carriers/eparcel/name'));
} else {
$method->setMethodTitle($rate['delivery_type']);
}
$method->setMethodChargeCodeIndividual($rate['charge_code_individual']);
$method->setMethodChargeCodeBusiness($rate['charge_code_business']);
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
$method->setPrice($shippingPrice);
$method->setCost($rate['cost']);
$method->setDeliveryType($rate['delivery_type']);
$result->append($method);
}
}
} else {
if (!empty($rates) && $rates['price'] >= 0) {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier('eparcel');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('bestway');
$method->setMethodTitle($this->getConfigData('name'));
$method->setMethodChargeCodeIndividual($rates['charge_code_individual']);
$method->setMethodChargeCodeBusiness($rates['charge_code_business']);
$shippingPrice = $this->getFinalPriceWithHandlingFee($rates['price']);
$method->setPrice($shippingPrice);
$method->setCost($rates['cost']);
$method->setDeliveryType($rates['delivery_type']);
$result->append($method);
}
}
return $result;
}
开发者ID:rob3000,项目名称:fontis_australia,代码行数:55,代码来源:Eparcel.php
示例18: 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;
}
$freeBoxes = 0;
if ($request->getAllItems()) {
foreach ($request->getAllItems() as $item) {
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
continue;
}
if ($item->getHasChildren() && $item->isShipSeparately()) {
foreach ($item->getChildren() as $child) {
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
$freeBoxes += $item->getQty() * $child->getQty();
}
}
} elseif ($item->getFreeShipping()) {
$freeBoxes += $item->getQty();
}
}
}
$this->setFreeBoxes($freeBoxes);
$result = Mage::getModel('shipping/rate_result');
if ($this->getConfigData('type') == 'O') {
// per order
$shippingPrice = $this->getConfigData('price');
} elseif ($this->getConfigData('type') == 'I') {
// per item
$shippingPrice = $request->getPackageQty() * $this->getConfigData('price') - $this->getFreeBoxes() * $this->getConfigData('price');
} else {
$shippingPrice = false;
}
$voucher_code = Mage::getSingleton('core/session')->getData('voucher_code');
$voucher = $this->verify_voucher_code($voucher_code);
if ($voucher['order_type'] == '3MM') {
$shippingPrice = 18;
}
$shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
if ($shippingPrice !== false) {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier('flatrate');
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod('flatrate');
$method->setMethodTitle($this->getConfigData('name'));
if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
$shippingPrice = '0.00';
}
$method->setPrice($shippingPrice);
$method->setCost($shippingPrice);
$result->append($method);
}
return $result;
}
开发者ID:Rodrifer,项目名称:candyclub,代码行数:60,代码来源:Flatrate.php
示例19: hasFreightItems
protected function hasFreightItems(Mage_Shipping_Model_Rate_Request $request)
{
$items = $request->getAllItems();
foreach ($items as $item) {
$product = Mage::getModel('catalog/product')->loadByAttribute('entity_id', $item->getProductId(), 'freight_class');
$freightClass = $product->getData('freight_class');
if (!empty($freightClass) && $freightClass != "") {
return true;
}
}
return false;
}
开发者ID:htecvc2x,项目名称:htecvc2x-mage-training,代码行数:12,代码来源:Shipping.php
示例20: collectRates
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
{
if (!$this->getConfigFlag('active')) {
return false;
}
$freeBoxes = 0;
$removeWeight = 0;
if ($request->getAllItems()) {
foreach ($request->getAllItems() as $item) {
if ($item->getFreeShipping() && !$item->getProduct()->getTypeInstance()->isVirtual()) {
$freeBoxes += $item->getQty();
$removeWeight += $item->getWeight() * $item->getQty();
}
}
}
$this->setFreeBoxes($freeBoxes);
$result = Mage::getModel('shipping/rate_result');
if (count($this->getAllowedMethods()) > 0) {
foreach ($this->getAllowedMethods() as $key => $value) {
$obj = Mage::getModel("royalmail/shipping_carrier_royalmail_{$key}");
if ($obj === false) {
Mage::log("Error loading royal mail: {$key}");
continue;
}
$obj->setWeightUnit($this->getConfigData('weight_unit'));
$obj->setNegativeWeight($removeWeight);
$cost = $obj->getCost($request);
if ($cost !== null) {
$method = Mage::getModel('shipping/rate_result_method');
$method->setCarrier($this->_code);
$method->setCarrierTitle($this->getConfigData('title'));
$method->setMethod($key);
$method->setMethodTitle($value);
if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
$price = '0.00';
} else {
$price = $this->_performRounding($this->getFinalPriceWithHandlingFee($cost));
}
$method->setPrice($price);
$method->setCost($price);
$result->append($method);
if ($price == '0.00') {
break;
// No more free methods
}
}
}
}
return $result;
}
开发者ID:JGMAgency,项目名称:royalmail,代码行数:50,代码来源:Royalmail.php
注:本文中的Mage_Shipping_Model_Rate_Request类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论