Ejemplo n.º 1
0
 /**
  * True is returned if the carrier address validation support (postcode, town)
  *
  * @param Mage_Shipping_Model_Carrier_Abstract $carrier
  * @param string                               $countryId
  *
  * @return boolean
  */
 public function carrierSupportsAddressValidation(Mage_Shipping_Model_Carrier_Abstract $carrier = null, $countryId = 'ES')
 {
     if ($carrier instanceof Zitec_PackedShipment_Model_Carrier_Interface) {
         return $carrier->supportsAddressValidation($countryId);
     }
     return false;
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     foreach ($this->getCode('condition_name') as $k => $v) {
         $this->_conditionNames[] = $k;
     }
 }
Ejemplo n.º 3
0
 public function checkAvailableShipCountries(Mage_Shipping_Model_Rate_Request $request)
 {
     // Get shipping value from session
     $ebayShippingData = Mage::registry('ebayShippingData');
     if (!$ebayShippingData) {
         // No data in session - this is frontend.
         if (!Mage::getStoreConfig('carriers/' . $this->_code . '/show_on_frontend')) {
             // Don't show on frontend
             return false;
         }
     }
     return parent::checkAvailableShipCountries($request);
 }
Ejemplo n.º 4
0
 public function __construct($registry)
 {
     parent::__construct($registry);
     if (Mage::getStoreConfig('carriers/' . $this->_code . '/sandbox')) {
         $this->_sandboxMode = true;
     } else {
         $this->_sandboxMode = false;
     }
     if ($this->_sandboxMode == false) {
         $this->PRODUCTION_KEY = Mage::getStoreConfig('carriers/' . $this->_code . '/prokey');
         $this->PRODUCTION_PASS = Mage::getStoreConfig('carriers/' . $this->_code . '/propass');
         $this->BILLING_ACCOUNT = Mage::getStoreConfig('carriers/' . $this->_code . '/billingaccount');
         $this->REGISTERED_ACCOUNT = Mage::getStoreConfig('carriers/' . $this->_code . '/registeredaccount');
     } else {
         $this->PRODUCTION_KEY = "57f5b17d6f4c43229f86b5cb0af78d0b";
         $this->PRODUCTION_PASS = "******";
         $this->BILLING_ACCOUNT = "9999999999";
         $this->REGISTERED_ACCOUNT = "9999999999";
     }
 }
Ejemplo n.º 5
0
 /**
  * Compose Packages For Carrier.
  * Devides order into items and items into parts if it's neccesary
  *
  * @param Mage_Shipping_Model_Carrier_Abstract $carrier
  * @param Mage_Shipping_Model_Rate_Request $request
  * @return array [int, float]
  */
 public function composePackagesForCarrier($carrier, $request)
 {
     $allItems = $request->getAllItems();
     $fullItems = array();
     $maxWeight = (double) $carrier->getConfigData('max_package_weight');
     foreach ($allItems as $item) {
         if ($item->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE && $item->getProduct()->getShipmentType()) {
             continue;
         }
         $qty = $item->getQty();
         $changeQty = true;
         $checkWeight = true;
         $decimalItems = array();
         if ($item->getParentItem()) {
             if (!$item->getParentItem()->getProduct()->getShipmentType()) {
                 continue;
             }
             $qty = $item->getIsQtyDecimal() ? $item->getParentItem()->getQty() : $item->getParentItem()->getQty() * $item->getQty();
         }
         $itemWeight = $item->getWeight();
         if ($item->getIsQtyDecimal() && $item->getProductType() != Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
             $stockItem = $item->getProduct()->getStockItem();
             if ($stockItem->getIsDecimalDivided()) {
                 if ($stockItem->getEnableQtyIncrements() && $stockItem->getQtyIncrements()) {
                     $itemWeight = $itemWeight * $stockItem->getQtyIncrements();
                     $qty = round($item->getWeight() / $itemWeight * $qty);
                     $changeQty = false;
                 } else {
                     $itemWeight = $itemWeight * $item->getQty();
                     if ($itemWeight > $maxWeight) {
                         $qtyItem = floor($itemWeight / $maxWeight);
                         $decimalItems[] = array('weight' => $maxWeight, 'qty' => $qtyItem);
                         $weightItem = Mage::helper('core')->getExactDivision($itemWeight, $maxWeight);
                         if ($weightItem) {
                             $decimalItems[] = array('weight' => $weightItem, 'qty' => 1);
                         }
                         $checkWeight = false;
                     } else {
                         $itemWeight = $itemWeight * $item->getQty();
                     }
                 }
             } else {
                 $itemWeight = $itemWeight * $item->getQty();
             }
         }
         if ($checkWeight && $maxWeight && $itemWeight > $maxWeight) {
             return array();
         }
         if ($changeQty && !$item->getParentItem() && $item->getIsQtyDecimal() && $item->getProductType() != Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
             $qty = 1;
         }
         if (!empty($decimalItems)) {
             foreach ($decimalItems as $decimalItem) {
                 $fullItems = array_merge($fullItems, array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight']));
             }
         } else {
             $fullItems = array_merge($fullItems, array_fill(0, $qty, $itemWeight));
         }
     }
     sort($fullItems);
     return $this->_makePieces($fullItems, $maxWeight);
 }
Ejemplo n.º 6
0
 /**
  * Class constructor.
  */
 public function __construct()
 {
     parent::__construct();
 }
 /**
  * get the title from the carrier
  *
  * @param Mage_Shipping_Model_Carrier_Abstract
  * @return string
  */
 protected function getCarrierTitle(Mage_Shipping_Model_Carrier_Abstract $model)
 {
     // ensure consistent scope when we're querying config data
     return $model->setStore($this->config->getStore())->getConfigData('title');
 }
Ejemplo n.º 8
0
 /**
  * @param array $data
  */
 public function __construct(array $data = array())
 {
     $this->_helper = Mage::helper('ch_ems');
     $this->_code = self::CARRIER_CODE;
     parent::__construct($data);
 }
 /**
  * Get the shipping method name using the passed in shipping method code
  *
  * @param  Mage_Shipping_Model_Carrier_Abstract
  * @param  string
  * @return string | null
  */
 protected function getShippingMethodName(Mage_Shipping_Model_Carrier_Abstract $carrier, $shippingMethodCode)
 {
     /** @var array */
     $shippingMethods = $carrier->getAllowedMethods();
     return isset($shippingMethods[$shippingMethodCode]) ? $shippingMethods[$shippingMethodCode] : null;
 }
Ejemplo n.º 10
0
 public function isActive()
 {
     $data = unserialize(base64_decode($this->getConfigData('shippingconfig')));
     if (!$data) {
         return false;
     }
     return parent::isActive();
 }