/**
  * Retrieve array of shipping rates groups
  *
  * @return array
  */
 public function getShippingRates()
 {
     if (Mage::helper('smdropship')->dropShipIsActive()) {
         if (empty($this->_rates)) {
             $groups = $this->getAddress()->getGroupedAllShippingRates();
             $dropShipCode = 'dropshipping';
             if (!empty($groups) and array_key_exists($dropShipCode, $groups)) {
                 return $this->_rates = array($dropShipCode => $groups[$dropShipCode]);
             }
         }
         return $this->_rates;
     }
     return parent::getShippingRates();
 }
Ejemplo n.º 2
0
 public function getShippingRates()
 {
     if (!Mage::helper('udsplit')->isActive()) {
         return parent::getShippingRates();
     }
     if (empty($this->_rates)) {
         $groups = array();
         // prepare vendor items
         $q = $this->getQuote();
         $qItems = $q->getAllVisibleItems();
         Mage::helper('udropship/protected')->prepareQuoteItems($qItems);
         foreach ($qItems as $item) {
             if ($item->getIsVirtual()) {
                 continue;
             }
             $groups[$item->getUdropshipVendor()]['items'][] = $item;
             $groups[$item->getUdropshipVendor()]['rates'] = array();
         }
         // prepare vendor rates
         $methods = array();
         $details = $this->getAddress()->getUdropshipShippingDetails();
         if ($details) {
             $details = Zend_Json::decode($details);
             $methods = isset($details['methods']) ? $details['methods'] : array();
         }
         $qRates = $this->getAddress()->getGroupedAllShippingRates();
         foreach ($qRates as $cCode => $cRates) {
             foreach ($cRates as $rate) {
                 $vId = $rate->getUdropshipVendor();
                 if (!$vId) {
                     continue;
                 }
                 $rate->setIsSelected(!empty($methods[$vId]['code']) && $methods[$vId]['code'] == $rate->getCarrier() . '_' . $rate->getMethod());
                 $groups[$vId]['rates'][$cCode][] = $rate;
             }
         }
         return $this->_rates = $groups;
     }
     return $this->_rates;
 }