示例#1
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     if (Mage::helper('gomage_checkout')->getConfigData('gift_wrapping/enable') > 0 && $address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING) {
         $items = $this->_getAddressItems($address);
         if (!count($items)) {
             return $this;
         }
         $addressQty = 0;
         foreach ($items as $item) {
             if ($item->getData('gomage_gift_wrap')) {
                 $addressQty++;
             }
         }
         if (!$addressQty) {
             return $this;
         }
         $gift_wrap_price = Mage::helper('gomage_checkout')->getConfigData('gift_wrapping/price');
         $this->_addAmount(Mage::helper('gomage_checkout')->getGiftWrapTaxAmount($address, $gift_wrap_price * $addressQty));
         $this->_addBaseAmount(Mage::helper('gomage_checkout')->getGiftWrapTaxAmount($address, $gift_wrap_price * $addressQty));
         $shippingDescription = $address->getShippingDescription();
         if ($shippingDescription) {
             $shippingDescription .= ' + ';
         }
         $shippingDescription .= Mage::helper('gomage_checkout')->getConfigData('gift_wrapping/title');
         $address->setShippingDescription($shippingDescription);
     }
     return $this;
 }
示例#2
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     if ($address->getShippingMethod() == 'umosaco_umosaco') {
         if ($rate = $address->getShippingRateByCode('umosaco_umosaco')) {
             $shippingOptions = unserialize($address->getQuote()->getData('emjainteractive_shippingoption'));
             $shippingOptions = $shippingOptions['umosaco'];
             if (isset($shippingOptions['Shipping Method']) && isset($shippingOptions['Shipping Service'])) {
                 $address->setShippingDescription($rate->getCarrierTitle() . " ({$shippingOptions['Shipping Method']} - {$shippingOptions['Shipping Service']})");
             }
         }
     }
     return $this;
 }
示例#3
0
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $model = Mage::getModel('ig_cashondelivery/cashondelivery');
     $amount = $address->getShippingAmount();
     if (($amount != 0 || $address->getShippingDescription()) && $this->getQuote()->getPayment()->getMethod() == $model->getCode() && $address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING) {
         $fee = $model->getExtraFee();
         $fee_excl = Mage::helper('tax')->getShippingPrice($fee, false);
         $address->setShippingAmount($address->getShippingAmount() + $fee_excl);
         $address->setBaseShippingAmount($address->getBaseShippingAmount() + $fee_excl);
         $address->setShippingDescription($address->getShippingDescription() . ' + ' . $model->getTitle());
     }
     return $this;
 }
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $method = $address->getShippingMethod();
     if ($method) {
         foreach ($address->getAllShippingRates() as $rate) {
             if ($rate->getCode() == $method) {
                 if ($rate->getFreightQuoteId()) {
                     $address->setFreightQuoteId($rate->getFreightQuoteId());
                 } else {
                     $address->setFreightQuoteId('');
                 }
                 break;
             }
         }
     }
     return $this;
 }
示例#5
0
 /**
  * Collect totals information about shipping
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_Sales_Model_Quote_Address_Total_Shipping
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $_code = 'customshippingrate';
     $method = $address->getShippingMethod();
     if ($method == $_code) {
         $amountPrice = $address->getQuote()->getStore()->convertPrice($address->getBaseShippingAmount(), false);
         if (Mage::helper('customshippingrate')->isMage13()) {
             $address->setShippingAmount($amountPrice);
             $address->setBaseShippingAmount($address->getBaseShippingAmount());
             $address->setGrandTotal($address->getGrandTotal() + $address->getShippingAmount());
             $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseShippingAmount());
         } else {
             $this->_setAddress($address);
             $this->_setAmount($amountPrice);
             $this->_setBaseAmount($address->getBaseShippingAmount());
         }
         return $this;
     } else {
         return parent::collect($address);
     }
 }
示例#6
0
 /**
  * Collect shipping amount individually for each item
  *
  * @param Mage_Sales_Model_Quote_Address $address
  * @return Mage_Sales_Model_Quote_Address_Total_Nominal_Shipping
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     $items = $address->getAllNominalItems();
     if (!count($items)) {
         return $this;
     }
     // estimate quote with all address items to get their row weights
     $this->_shouldGetAllItems = true;
     parent::collect($address);
     $address->setCollectShippingRates(true);
     $this->_shouldGetAllItems = false;
     // now $items contains row weight information
     // collect shipping rates for each item individually
     foreach ($items as $item) {
         if (!$item->getProduct()->isVirtual()) {
             $address->requestShippingRates($item);
             $baseAmount = $item->getBaseShippingAmount();
             if ($baseAmount) {
                 $item->setShippingAmount($address->getQuote()->getStore()->convertPrice($baseAmount, false));
             }
         }
     }
     return $this;
 }
示例#7
0
 /**
  * Collect totals information about shipping
  *
  * @param   Mage_Sales_Model_Quote_Address $address
  * @return  Mage_Sales_Model_Quote_Address_Total_Shipping
  */
 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     $oldWeight = $address->getWeight();
     $address->setWeight(0);
     $address->setFreeMethodWeight(0);
     $this->_setAmount(0)->_setBaseAmount(0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $method = $address->getShippingMethod();
     $freeAddress = $address->getFreeShipping();
     $addressWeight = $address->getWeight();
     $freeMethodWeight = $address->getFreeMethodWeight();
     $addressQty = 0;
     foreach ($items as $item) {
         /**
          * Skip if this item is virtual
          */
         if ($item->getProduct()->isVirtual()) {
             continue;
         }
         /**
          * Children weight we calculate for parent
          */
         if ($item->getParentItem()) {
             continue;
         }
         if ($item->getHasChildren() && $item->isShipSeparately()) {
             foreach ($item->getChildren() as $child) {
                 if ($child->getProduct()->isVirtual()) {
                     continue;
                 }
                 $addressQty += $child->getTotalQty();
                 if (!$item->getProduct()->getWeightType()) {
                     $itemWeight = $child->getWeight();
                     $itemQty = $child->getTotalQty();
                     $rowWeight = $itemWeight * $itemQty;
                     $addressWeight += $rowWeight;
                     if ($freeAddress || $child->getFreeShipping() === true) {
                         $rowWeight = 0;
                     } elseif (is_numeric($child->getFreeShipping())) {
                         $freeQty = $child->getFreeShipping();
                         if ($itemQty > $freeQty) {
                             $rowWeight = $itemWeight * ($itemQty - $freeQty);
                         } else {
                             $rowWeight = 0;
                         }
                     }
                     $freeMethodWeight += $rowWeight;
                     $item->setRowWeight($rowWeight);
                 }
             }
             if ($item->getProduct()->getWeightType()) {
                 $itemWeight = $item->getWeight();
                 $rowWeight = $itemWeight * $item->getQty();
                 $addressWeight += $rowWeight;
                 if ($freeAddress || $item->getFreeShipping() === true) {
                     $rowWeight = 0;
                 } elseif (is_numeric($item->getFreeShipping())) {
                     $freeQty = $item->getFreeShipping();
                     if ($item->getQty() > $freeQty) {
                         $rowWeight = $itemWeight * ($item->getQty() - $freeQty);
                     } else {
                         $rowWeight = 0;
                     }
                 }
                 $freeMethodWeight += $rowWeight;
                 $item->setRowWeight($rowWeight);
             }
         } else {
             if (!$item->getProduct()->isVirtual()) {
                 $addressQty += $item->getQty();
             }
             $itemWeight = $item->getWeight();
             $rowWeight = $itemWeight * $item->getQty();
             $addressWeight += $rowWeight;
             if ($freeAddress || $item->getFreeShipping() === true) {
                 $rowWeight = 0;
             } elseif (is_numeric($item->getFreeShipping())) {
                 $freeQty = $item->getFreeShipping();
                 if ($item->getQty() > $freeQty) {
                     $rowWeight = $itemWeight * ($item->getQty() - $freeQty);
                 } else {
                     $rowWeight = 0;
                 }
             }
             $freeMethodWeight += $rowWeight;
             $item->setRowWeight($rowWeight);
         }
     }
     if (isset($addressQty)) {
         $address->setItemQty($addressQty);
     }
     $address->setWeight($addressWeight);
     $address->setFreeMethodWeight($freeMethodWeight);
     $address->collectShippingRates();
     $this->_setAmount(0)->_setBaseAmount(0);
     $method = $address->getShippingMethod();
     if ($method) {
         foreach ($address->getAllShippingRates() as $rate) {
             if ($rate->getCode() == $method) {
                 $amountPrice = $address->getQuote()->getStore()->convertPrice($rate->getPrice(), false);
                 $this->_setAmount($amountPrice);
                 $this->_setBaseAmount($rate->getPrice());
                 $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
                 $address->setShippingDescription(trim($shippingDescription, ' -'));
                 break;
             }
         }
     }
     return $this;
 }