示例#1
0
 public function collectCarrierRates($carrierCode, $request)
 {
     if (!$this->_checkCarrierAvailability($carrierCode, $request)) {
         return $this;
     }
     return parent::collectCarrierRates($carrierCode, $request);
 }
示例#2
0
 /**
  * @param string $carrierCode
  * @param Varien_Object $request
  * @return N98_CheckoutFilters_Model_Shipping_Shipping
  */
 public function collectCarrierRates($carrierCode, $request)
 {
     if (!$this->_checkCarrierByCustomerGroup($carrierCode)) {
         return $this;
     }
     return parent::collectCarrierRates($carrierCode, $request);
 }
示例#3
0
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     parent::collectRates($request);
     $result = $this->getResult();
     Mage::dispatchEvent('am_restrict_rates', array('request' => $request, 'result' => $result));
     return $this;
 }
 /**
  * Get the shipping method using the shipping code.
  *
  * @param  string
  * @return string | null
  */
 protected function getShippingMethod($shipping)
 {
     $data = array_filter(explode('_', $shipping));
     if (count($data) > 1) {
         /** @var string */
         $shippingCode = $data[0];
         /** @var string */
         $shippingMethodCode = $data[1];
         /** @var Mage_Shipping_Model_Carrier_Abstract | false */
         $carrier = $this->shipping->getCarrierByCode($shippingCode);
         return $carrier ? sprintf('%s - %s', $carrier->getConfigData('title'), $this->getShippingMethodName($carrier, $shippingMethodCode)) : null;
     }
     return null;
 }
 public function getCarrierByCode($carrierCode, $storeId = null)
 {
     if ($carrierCode == 'imported') {
         $className = Mage::getStoreConfig('carriers/' . $carrierCode . '/model', $storeId);
         if (!$className) {
             return false;
         }
         $obj = Mage::getModel($className);
         if ($storeId) {
             $obj->setStore($storeId);
         }
         return $obj;
     } else {
         return parent::getCarrierByCode($carrierCode, $storeId);
     }
 }
 /**
  * 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 (!Mage::getStoreConfig('carriers/wsaupsfreight/active')) {
         return parent::collectRates($request);
     }
     $restrictRates = Mage::getStoreConfig('carriers/wsaupsfreight/restrict_rates');
     $forceFreight = Mage::getStoreConfig('carriers/wsaupsfreight/force_freight');
     $hasFreightItems = $this->hasFreightItems($request);
     $limitCarrier = $request->getLimitCarrier();
     if ($restrictRates && Mage::getStoreConfig('carriers/wsaupsfreight/weight_apply') == 'Order' && $request->getPackageWeight() >= Mage::getStoreConfig('carriers/wsaupsfreight/min_weight') || $forceFreight && $hasFreightItems) {
         if (!$limitCarrier) {
             $limitCarrier = array();
         } else {
             if (!is_array($limitCarrier)) {
                 $limitCarrier = array($limitCarrier);
             }
         }
         $limitCarrier[] = 'wsaupsfreight';
         $request->setLimitCarrier($limitCarrier);
     } else {
         if ($request->getPackageWeight() < Mage::getStoreConfig('carriers/wsaupsfreight/min_weight') && !$hasFreightItems) {
             if (!$limitCarrier) {
                 $carriers = Mage::getStoreConfig('carriers', $request->getStoreId());
                 foreach ($carriers as $carrierCode => $carrierConfig) {
                     if ($carrierCode == 'wsaupsfreight') {
                         continue;
                     }
                     $limitCarrier[] = $carrierCode;
                 }
             } else {
                 if (!is_array($limitCarrier)) {
                     $limitCarrier = array($limitCarrier);
                 }
                 foreach ($limitCarrier as $carrierCode => $carrierConfig) {
                     if ($carrierCode == 'wsaupsfreight') {
                         continue;
                     }
                     $limitCarrier[] = $carrierCode;
                 }
             }
             $request->setLimitCarrier($limitCarrier);
         }
     }
     return parent::collectRates($request);
 }
 public function collectCarrierRates($carrierCode, $request)
 {
     $helper = Mage::helper('milkman_deliveries/data');
     $helper->log("shipping rewrite: collectCarrierRates: '{$carrierCode}''");
     if (!$helper->isActive()) {
         $helper->log("shipping rewrite: collectCarrierRates: Miklkman NOT active: return to parent");
         return parent::collectCarrierRates($carrierCode, $request);
     }
     $eligible = $helper->isEligible();
     // if Milkman eligible: exclude other shipping methods
     if ($eligible && $carrierCode != 'milkman_deliveries') {
         return $this;
     }
     // if Milkman not eligible: exclude Milkman deliveries
     if (!$eligible && $carrierCode == 'milkman_deliveries') {
         return $this;
     }
     return parent::collectCarrierRates($carrierCode, $request);
 }
示例#8
0
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     parent::collectRates($request);
     //var_dump($request);
     $parametros = array('email' => Mage::getStoreConfig('squidfacil/squidfacil_group/squidfacil_email', Mage::app()->getStore()), 'token' => Mage::getStoreConfig('squidfacil/squidfacil_group/squidfacil_token', Mage::app()->getStore()), 'cep' => $request->getDestPostcode());
     $items = $request->getData('all_items');
     foreach ($items as $item) {
         $parametros['products'][] = array('sku' => $item->getSku(), 'quantity' => $item->getQty());
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, "https://www.squidfacil.com.br/webservice/freight/freight.php");
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parametros));
     $response = curl_exec($ch);
     curl_close($ch);
     $xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
     if ($xml) {
         $root = $xml->children();
         foreach ($root->carrier as $externalCarrier) {
             $carrier = new SquidFacil_Shipping_Model_Carrier_Abstract();
             $carrier->setCode('squidfacil_' . strtolower($externalCarrier->name));
             foreach ($externalCarrier->service as $service) {
                 $method = new Mage_Shipping_Model_Rate_Result_Method();
                 $method->setCarrier((string) $externalCarrier->name);
                 $method->setCarrierTitle((string) $externalCarrier->name);
                 $method->setMethod(strtolower((string) $service->name));
                 $method->setMethodTitle((string) $service->name);
                 $method->setPrice((double) $service->value);
                 $carrier->setRate($method);
             }
             $this->getResult()->append($carrier->collectRates($request));
         }
     }
     return $this;
 }
示例#9
0
 /**
  * Retrieve all methods for supplied shipping data
  *
  * @param Mage_Shipping_Model_Shipping_Method_Request $data
  * @return Mage_Shipping_Model_Shipping
  */
 public function collectRates(Mage_Shipping_Model_Rate_Request $request)
 {
     parent::collectRates($request);
     $result = $this->getResult();
     Mage::dispatchEvent('am_restrict_rates', array('request' => $request, 'result' => $result));
     $oldRates = $result->getAllRates();
     $oldPrices = $this->_getPrices($oldRates);
     $newRates = array();
     $validator = Mage::getSingleton('amshiprules/validator');
     $validator->init($request);
     if (!$validator->canApplyFor($oldRates)) {
         return $this;
     }
     $validator->applyRulesTo($oldRates);
     foreach ($oldRates as $rate) {
         if ($validator->needNewRequest($rate)) {
             $newRequest = $validator->getNewRequest($rate);
             if (count($newRequest->getAllItems())) {
                 $result->reset();
                 parent::collectRates($newRequest);
                 $rate = $validator->findRate($result->getAllRates(), $rate);
             } else {
                 $rate->setPrice(0);
             }
         }
         $rate->setPrice($rate->getPrice() + $validator->getFee($rate));
         $newRates[] = $rate;
     }
     $result->reset();
     foreach ($newRates as $rate) {
         $rate->setOldPrice($oldPrices[$rate->getMethod()]);
         $rate->setPrice(max(0, $rate->getPrice()));
         $result->append($rate);
     }
     return $this;
 }
 /**
  * Overrides this method in core, and decides which extension to call
  * Uses a hierarchy to decide on best extension
  * @see app/code/core/Mage/Shipping/Model/Mage_Shipping_Model_Shipping::collectCarrierRates()
  */
 public function collectCarrierRates($carrierCode, $request)
 {
     // check to see if handling Product enabled
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Handlingproduct')) {
         if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Shipusa')) {
             return parent::collectCarrierRates($carrierCode, $request);
         } else {
             if (!Mage::registry('handlingproduct_shipmodel')) {
                 $model = Mage::getModel('handlingproduct/shipping_shipping');
                 Mage::register('handlingproduct_shipmodel', $model);
             }
             $model = Mage::registry('handlingproduct_shipmodel');
             $model->collectCarrierRates($carrierCode, $request);
             $this->_result = $model->getResult();
             return $model;
         }
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Insurance')) {
         if (!Mage::registry('insurance_shipmodel')) {
             $model = Mage::getModel('insurance/shipping_shipping');
             Mage::register('insurance_shipmodel', $model);
         }
         $model = Mage::registry('insurance_shipmodel');
         $model->collectCarrierRates($carrierCode, $request);
         $this->_result = $model->getResult();
         return $model;
     }
     // default
     return parent::collectCarrierRates($carrierCode, $request);
 }
示例#11
0
 /**
  * Overrides this method in core, and decides which extension to call
  * Uses a hierarchy to decide on best extension
  * @see app/code/core/Mage/Shipping/Model/Mage_Shipping_Model_Shipping::collectCarrierRates()
  */
 public function collectCarrierRates($carrierCode, $request)
 {
     // check to see if handling Product enabled
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Handlingproduct', 'shipping/handlingproduct/active')) {
         if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Shipusa', 'shipping/shipusa/active')) {
             return parent::collectCarrierRates($carrierCode, $request);
         } else {
             if (!Mage::registry('handlingproduct_shipmodel')) {
                 $model = Mage::getModel('handlingproduct/shipping_shipping');
                 Mage::register('handlingproduct_shipmodel', $model);
             }
             $model = Mage::registry('handlingproduct_shipmodel');
             $model->collectCarrierRates($carrierCode, $request);
             $this->_result = $model->getResult();
             return $model;
         }
     }
     // This method of handling rewrites is now deprecated in favour of using event logic for handling matrix
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Handlingmatrix', 'shipping/handlingmatrix/active') && Mage::helper('wsacommon')->getNumericExtensionVersion('handlingmatrix') < 100) {
         if (!Mage::registry('handlingmatrix_shipmodel')) {
             $model = Mage::getModel('handlingmatrix/shipping_shipping');
             Mage::register('handlingmatrix_shipmodel', $model);
         }
         $model = Mage::registry('handlingmatrix_shipmodel');
         $model->collectCarrierRates($carrierCode, $request);
         $this->_result = $model->getResult();
         return $model;
     }
     if (Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Insurance', 'shipping/insurance/active')) {
         if (!Mage::registry('insurance_shipmodel')) {
             $model = Mage::getModel('insurance/shipping_shipping');
             Mage::register('insurance_shipmodel', $model);
         }
         $model = Mage::registry('insurance_shipmodel');
         $model->collectCarrierRates($carrierCode, $request);
         $this->_result = $model->getResult();
         return $model;
     }
     // default
     return parent::collectCarrierRates($carrierCode, $request);
 }