/**
  * Add price details to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @param Mage_Sales_Model_Quote_Address_Rate $rate
  * @return Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
  */
 protected function _addPriceToXmlObj($xmlObj, $rate)
 {
     $price = $this->_getShippingPrice($rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax());
     $incl = $this->_getShippingPrice($rate->getPrice(), true);
     $renderedInclTax = '';
     if ($incl != $price && $this->helper('tax')->displayShippingBothPrices()) {
         $inclTaxFormat = ' (%s %s)';
         $renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
     }
     $price .= $renderedInclTax;
     $xmlObj->addAttribute('price', $rate->getPrice() * 1);
     $xmlObj->addAttribute('formatted_price', $xmlObj->escapeXml($price));
     return $this;
 }
Esempio n. 2
0
 /**
  * Overwrite parent method to check codes based on easyshippingmethod
  * and retrieving properly carrier
  *
  * @return Mage_Shipping_Model_Carrier_Abstract
  */
 public function getCarrierInstance()
 {
     $code = $this->getCarrier();
     // checking if code starts with easyshippingrules code
     if (!isset(self::$_instances[$code]) && strpos($code, MatheusGontijo_EasyShippingRules_Model_Shipping_Carrier::EASY_SHIPPING_RULES_CODE) === 0) {
         self::$_instances[$code] = Mage::getModel('easyshippingrules/shipping_carrier');
     }
     return parent::getCarrierInstance();
 }
Esempio n. 3
0
 public function importShippingRate(Mage_Shipping_Model_Rate_Result_Abstract $rate)
 {
     if (!Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Dropship', 'carriers/dropship/active') && !Mage::helper('wsacommon')->isModuleEnabled('Webshopapps_Wsafreightcommon', 'shipping/wsafreightcommon/active')) {
         return parent::importShippingRate($rate);
     }
     if ($rate instanceof Mage_Shipping_Model_Rate_Result_Error) {
         $this->setCode($rate->getCarrier() . '_error')->setCarrier($rate->getCarrier())->setCarrierTitle($rate->getCarrierTitle())->setWarehouse($rate->getWarehouse())->setWarehouseShippingDetails($rate->getWarehouseShippingDetails())->setErrorMessage($rate->getErrorMessage());
     } elseif ($rate instanceof Mage_Shipping_Model_Rate_Result_Method) {
         $this->setCode($rate->getCarrier() . '_' . $rate->getMethod())->setCarrier($rate->getCarrier())->setCarrierTitle($rate->getCarrierTitle())->setMethod($rate->getMethod())->setWarehouse($rate->getWarehouse())->setWarehouseShippingDetails($rate->getWarehouseShippingDetails())->setExpectedDelivery($rate->getExpectedDelivery())->setDispatchDate($rate->getDispatchDate())->setFreightQuoteId($rate->getFreightQuoteId())->setMethodTitle($rate->getMethodTitle())->setMethodDescription($rate->getMethodDescription())->setOverridePriceInfo($rate->getOverridePriceInfo())->setPrice($rate->getPrice());
     }
     return $this;
 }
Esempio n. 4
0
 /**
  * Add shipping rate
  *
  * @param Mage_Sales_Model_Quote_Address_Rate $rate
  * @return Mage_Sales_Model_Quote_Address
  */
 public function addShippingRate(Mage_Sales_Model_Quote_Address_Rate $rate)
 {
     $rate->setAddress($this);
     $this->getShippingRatesCollection()->addItem($rate);
     return $this;
 }
Esempio n. 5
0
 /**
  * Add shipping rate
  *
  * @param Mage_Sales_Model_Quote_Address_Rate $rate
  * @return Mage_Sales_Model_Quote_Address
  */
 public function addShippingRate($rate)
 {
     $rate->setAddress($this);
     $this->getShippingRatesCollection()->addItem($rate);
     return $this;
 }
Esempio n. 6
0
 public function importShippingRate(Mage_Shipping_Model_Rate_Result_Abstract $rate)
 {
     parent::importShippingRate($rate);
     $this->setUdropshipVendor($rate->getUdropshipVendor());
     return $this;
 }
Esempio n. 7
0
 public function importShippingRate(Mage_Shipping_Model_Rate_Result_Abstract $rate)
 {
     parent::importShippingRate($rate);
     $this->setAdditionalInfo($rate->getAdditionalInfo());
     return $this;
 }
 /**
  * Retrieve carrier position based on a rate
  *
  * @param Mage_Sales_Model_Quote_Address_Rate $rate
  *
  * @return int
  */
 protected function _getEasyShippingRulesSortOrder(Mage_Sales_Model_Quote_Address_Rate $rate)
 {
     $carrierExploded = explode('_', $rate->getCarrier());
     $carrierId = isset($carrierExploded[1]) ? $carrierExploded[1] : 0;
     return Mage::getModel('easyshippingrules/carrier')->load($carrierId)->getPosition();
 }
Esempio n. 9
0
 public function importShippingRate(Mage_Shipping_Model_Rate_Result_Abstract $rate)
 {
     $rateData = parent::importShippingRate($rate);
     $rateData->setOldPrice($rate->getOldPrice());
     return $rateData;
 }
Esempio n. 10
0
 protected function sortRates(Mage_Sales_Model_Quote_Address_Rate $a, Mage_Sales_Model_Quote_Address_Rate $b)
 {
     // Sort by price (lowest first)
     // This is a crappy solution and should be rewritten
     $aSort = intval(round(floatval($a->getPrice()) * 10000));
     $bSort = intval(round(floatval($b->getPrice()) * 10000));
     if ($aSort < $bSort) {
         return -1;
     } elseif ($aSort > $bSort) {
         return 1;
     }
     // Sory by carrier order (lowest first)
     $aSort = $a->getCarrierInstance()->getSortOrder();
     $bSort = $b->getCarrierInstance()->getSortOrder();
     if ($aSort < $bSort) {
         return -1;
     } elseif ($aSort > $bSort) {
         return 1;
     }
     // Sort my method order (lowest first)
     $aSort = intval($a->getSortOrder());
     $bSort = intval($b->getSortOrder());
     if ($aSort < $bSort) {
         return -1;
     } elseif ($aSort > $bSort) {
         return 1;
     }
     return 0;
 }