Пример #1
0
 public function setRequest(Mage_Shipping_Model_Rate_Request $request)
 {
     $this->_request = $request;
     $r = new Varien_Object();
     if ($request->getLimitMethod()) {
         $r->setAction($this->getCode('action', 'single'));
         $r->setProduct($request->getLimitMethod());
     } else {
         $r->setAction($this->getCode('action', 'all'));
         $r->setProduct('GNDRES');
     }
     if ($request->getUpsPickup()) {
         $pickup = $request->getUpsPickup();
     } else {
         $pickup = $this->getConfigData('pickup');
     }
     $r->setPickup($this->getCode('pickup', $pickup));
     if ($request->getUpsContainer()) {
         $container = $request->getUpsContainer();
     } else {
         $container = $this->getConfigData('container');
     }
     $r->setContainer($this->getCode('container', $container));
     if ($request->getUpsDestType()) {
         $destType = $request->getUpsDestType();
     } else {
         $destType = $this->getConfigData('dest_type');
     }
     $r->setDestType($this->getCode('dest_type', $destType));
     if ($request->getOrigCountry()) {
         $origCountry = $request->getOrigCountry();
     } else {
         $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore());
     }
     $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code());
     if ($request->getOrigPostcode()) {
         $r->setOrigPostal($request->getOrigPostcode());
     } else {
         $r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()));
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code());
     if ($request->getDestPostcode()) {
         $r->setDestPostal($request->getDestPostcode());
     } else {
     }
     $r->setWeight($request->getPackageWeight());
     if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
         $r->setFreeMethodWeight($request->getFreeMethodWeight());
     }
     $r->setValue($request->getPackageValue());
     if ($request->getUpsUnitMeasure()) {
         $unit = $request->getUpsUnitMeasure();
     } else {
         $unit = $this->getConfigData('unit_of_measure');
     }
     $r->setUnitMeasure($unit);
     $this->_rawRequest = $r;
     return $this;
 }
Пример #2
0
 /**
  * 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)
 {
     $this->_request = $request;
     $r = new Varien_Object();
     if ($request->getLimitMethod()) {
         $r->setAction($this->getCode('action', 'single'));
         $r->setProduct($request->getLimitMethod());
     } else {
         $r->setAction($this->getCode('action', 'all'));
         $r->setProduct('GND' . $this->getConfigData('dest_type'));
     }
     if ($request->getUpsPickup()) {
         $pickup = $request->getUpsPickup();
     } else {
         $pickup = $this->getConfigData('pickup');
     }
     $r->setPickup($this->getCode('pickup', $pickup));
     if ($request->getUpsContainer()) {
         $container = $request->getUpsContainer();
     } else {
         $container = $this->getConfigData('container');
     }
     $r->setContainer($this->getCode('container', $container));
     if ($request->getUpsDestType()) {
         $destType = $request->getUpsDestType();
     } else {
         $destType = $this->getConfigData('dest_type');
     }
     $r->setDestType($this->getCode('dest_type', $destType));
     if ($request->getOrigCountry()) {
         $origCountry = $request->getOrigCountry();
     } else {
         $origCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId());
     }
     $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code());
     if ($request->getOrigRegionCode()) {
         $origRegionCode = $request->getOrigRegionCode();
     } else {
         $origRegionCode = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, $request->getStoreId());
     }
     if (is_numeric($origRegionCode)) {
         $origRegionCode = Mage::getModel('directory/region')->load($origRegionCode)->getCode();
     }
     $r->setOrigRegionCode($origRegionCode);
     if ($request->getOrigPostcode()) {
         $r->setOrigPostal($request->getOrigPostcode());
     } else {
         $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId()));
     }
     if ($request->getOrigCity()) {
         $r->setOrigCity($request->getOrigCity());
     } else {
         $r->setOrigCity(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, $request->getStoreId()));
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     //for UPS, puero rico state for US will assume as puerto rico country
     if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID)) {
         $destCountry = self::PUERTORICO_COUNTRY_ID;
     }
     // For UPS, Guam state of the USA will be represented by Guam country
     if ($destCountry == self::USA_COUNTRY_ID && $request->getDestRegionCode() == self::GUAM_REGION_CODE) {
         $destCountry = self::GUAM_COUNTRY_ID;
     }
     $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code());
     $r->setDestRegionCode($request->getDestRegionCode());
     if ($request->getDestPostcode()) {
         $r->setDestPostal($request->getDestPostcode());
     } else {
     }
     $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
     $weight = $this->_getCorrectWeight($weight);
     $r->setWeight($weight);
     if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
         $r->setFreeMethodWeight($request->getFreeMethodWeight());
     }
     $r->setValue($request->getPackageValue());
     $r->setValueWithDiscount($request->getPackageValueWithDiscount());
     if ($request->getUpsUnitMeasure()) {
         $unit = $request->getUpsUnitMeasure();
     } else {
         $unit = $this->getConfigData('unit_of_measure');
     }
     $r->setUnitMeasure($unit);
     $r->setIsReturn($request->getIsReturn());
     $this->_rawRequest = $r;
     return $this;
 }
Пример #3
0
 public function setRequest(Mage_Shipping_Model_Rate_Request $request)
 {
     $this->_request = $request;
     $r = new Varien_Object();
     if ($request->getLimitMethod()) {
         $r->setAction($this->getCode('action', 'single'));
         $r->setProduct($request->getLimitMethod());
     } else {
         $r->setAction($this->getCode('action', 'all'));
         $r->setProduct('GND' . $this->getConfigData('dest_type'));
     }
     if ($request->getUpsPickup()) {
         $pickup = $request->getUpsPickup();
     } else {
         $pickup = $this->getConfigData('pickup');
     }
     $r->setPickup($this->getCode('pickup', $pickup));
     if ($request->getUpsContainer()) {
         $container = $request->getUpsContainer();
     } else {
         $container = $this->getConfigData('container');
     }
     $r->setContainer($this->getCode('container', $container));
     if ($request->getUpsDestType()) {
         $destType = $request->getUpsDestType();
     } else {
         $destType = $this->getConfigData('dest_type');
     }
     $r->setDestType($this->getCode('dest_type', $destType));
     if ($request->getOrigCountry()) {
         $origCountry = $request->getOrigCountry();
     } else {
         $origCountry = AO::getStoreConfig('shipping/origin/country_id', $this->getStore());
     }
     $r->setOrigCountry(AO::getModel('directory/country')->load($origCountry)->getIso2Code());
     if ($request->getOrigRegionCode()) {
         $origRegionCode = $request->getOrigRegionCode();
     } else {
         $origRegionCode = AO::getStoreConfig('shipping/origin/region_id', $this->getStore());
         if (is_numeric($origRegionCode)) {
             $origRegionCode = AO::getModel('directory/region')->load($origRegionCode)->getCode();
         }
     }
     $r->setOrigRegionCode($origRegionCode);
     if ($request->getOrigPostcode()) {
         $r->setOrigPostal($request->getOrigPostcode());
     } else {
         $r->setOrigPostal(AO::getStoreConfig('shipping/origin/postcode', $this->getStore()));
     }
     if ($request->getOrigCity()) {
         $r->setOrigCity($request->getOrigCity());
     } else {
         $r->setOrigCity(AO::getStoreConfig('shipping/origin/city', $this->getStore()));
     }
     if ($request->getDestCountryId()) {
         $destCountry = $request->getDestCountryId();
     } else {
         $destCountry = self::USA_COUNTRY_ID;
     }
     //for UPS, puero rico state for US will assume as puerto rico country
     if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID)) {
         $destCountry = self::PUERTORICO_COUNTRY_ID;
     }
     $r->setDestCountry(AO::getModel('directory/country')->load($destCountry)->getIso2Code());
     $r->setDestRegionCode($request->getDestRegionCode());
     if ($request->getDestPostcode()) {
         $r->setDestPostal($request->getDestPostcode());
     } else {
     }
     $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
     $r->setWeight($weight);
     if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
         $r->setFreeMethodWeight($request->getFreeMethodWeight());
     }
     $r->setValue($request->getPackageValue());
     $r->setValueWithDiscount($request->getPackageValueWithDiscount());
     if ($request->getUpsUnitMeasure()) {
         $unit = $request->getUpsUnitMeasure();
     } else {
         $unit = $this->getConfigData('unit_of_measure');
     }
     $r->setUnitMeasure($unit);
     $this->_rawRequest = $r;
     return $this;
 }