Ejemplo n.º 1
0
 /**
  * Get basket shipping set, if shipping set id is not set, try to get it from session
  *
  * @return string oxDeliverySet
  */
 public function getShippingId()
 {
     if (!$this->_sShippingSetId) {
         $this->_sShippingSetId = oxSession::getVar('sShipSet');
     }
     $sActPaymentId = $this->getPaymentId();
     // setting default if none is set
     if (!$this->_sShippingSetId && $sActPaymentId != 'oxempty') {
         $oUser = $this->getUser();
         // choosing first preferred delivery set
         list(, $sActShipSet) = oxDeliverySetList::getInstance()->getDeliverySetData(null, $oUser, $this);
         // in case nothing was found and no user set - choosing default
         $this->_sShippingSetId = $sActShipSet ? $sActShipSet : ($oUser ? null : 'oxidstandard');
     } elseif (!$this->isAdmin() && $sActPaymentId == 'oxempty') {
         // in case 'oxempty' is payment id - delivery set must be reset
         $this->_sShippingSetId = null;
     }
     return $this->_sShippingSetId;
 }
Ejemplo n.º 2
0
 /**
  * Template variable getter. Returns paymentlist
  *
  * @return object
  */
 public function getPaymentList()
 {
     if ($this->_oPaymentList === null) {
         $this->_oPaymentList = false;
         $sActShipSet = oxConfig::getParameter('sShipSet');
         if (!$sActShipSet) {
             $sActShipSet = oxSession::getVar('sShipSet');
         }
         $oBasket = $this->getSession()->getBasket();
         // load sets, active set, and active set payment list
         list($aAllSets, $sActShipSet, $aPaymentList) = oxDeliverySetList::getInstance()->getDeliverySetData($sActShipSet, $this->getUser(), $oBasket);
         $oBasket->setShipping($sActShipSet);
         // calculating payment expences for preview for each payment
         $this->_setDeprecatedValues($aPaymentList, $oBasket);
         $this->_oPaymentList = $aPaymentList;
         $this->_aAllSets = $aAllSets;
     }
     return $this->_oPaymentList;
 }
Ejemplo n.º 3
0
 /**
  * Function checks if loaded payment is valid to current basket
  *
  * @param array  $aDynvalue    dynamical value (in this case oxidcreditcard and oxiddebitnote are checked only)
  * @param string $sShopId      id of current shop
  * @param oxuser $oUser        the current user
  * @param double $dBasketPrice the current basket price (oBasket->dprice)
  * @param string $sShipSetId   the current ship set
  *
  * @return bool true if payment is valid
  */
 public function isValidPayment($aDynvalue, $sShopId, $oUser, $dBasketPrice, $sShipSetId)
 {
     $myConfig = $this->getConfig();
     if ($this->oxpayments__oxid->value == 'oxempty') {
         // inactive or blOtherCountryOrder is off
         if (!$this->oxpayments__oxactive->value || !$myConfig->getConfigParam("blOtherCountryOrder")) {
             $this->_iPaymentError = -2;
             return false;
         }
         if (count(oxDeliverySetList::getInstance()->getDeliverySetList($oUser, $oUser->getActiveCountry()))) {
             $this->_iPaymentError = -3;
             return false;
         }
         return true;
     }
     if (!oxInputValidator::getInstance()->validatePaymentInputData($this->oxpayments__oxid->value, $aDynvalue)) {
         $this->_iPaymentError = 1;
         return false;
     }
     $oCur = $myConfig->getActShopCurrencyObject();
     $dBasketPrice = $dBasketPrice / $oCur->rate;
     if ($sShipSetId) {
         $aPaymentList = oxPaymentList::getInstance()->getPaymentList($sShipSetId, $dBasketPrice, $oUser);
         if (!array_key_exists($this->getId(), $aPaymentList)) {
             $this->_iPaymentError = -3;
             return false;
         }
     } else {
         $this->_iPaymentError = -2;
         return false;
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Returns the OXID delivery set list.
  *
  * @return oxDeliverySetList
  */
 public function getDeliverySetList()
 {
     return oxDeliverySetList::getInstance();
 }
 /**
  * Loads and returns list of deliveries.
  *
  * Process:
  *
  *  - first checks if delivery loading is enabled in config -
  *    $myConfig->bl_perfLoadDelivery is TRUE;
  *  - loads deliveryset list by calling this::GetDeliverySetList(...);
  *  - checks if there is any active (eg. chosen delset in order
  *    process etc) deliveryset defined and if its set - rearanges
  *    delivery set list by storing active set at the beginning in the
  *    list.
  *  - goes through delsets and loads its deliveries, checks if any
  *    delivery fits. By checking calculates and stores conditional
  *    amounts:
  *
  *       oDelivery->iItemCnt - items in basket that fits this delivery
  *       oDelivery->iProdCnt - products in basket that fits this delivery
  *       oDelivery->dPrice   - price of products that fits this delivery
  *
  *  - returns a list of deliveries.
  *    NOTICE: for performance reasons deliveries is cached in
  *    $myConfig->aDeliveryList.
  *
  * @param object $oBasket     basket object
  * @param oxuser $oUser       session user
  * @param string $sDelCountry user country id
  * @param string $sDelSet     delivery set id
  *
  * @return array
  */
 public function getDeliveryList($oBasket, $oUser = null, $sDelCountry = null, $sDelSet = null)
 {
     // ids of deliveries that doesnt fit for us to skip double check
     $aSkipDeliveries = array();
     $aDelSetList = oxDeliverySetList::getInstance()->getDeliverySetList($oUser, $sDelCountry, $sDelSet);
     // must choose right delivery set to use its delivery list
     foreach ($aDelSetList as $sDeliverySetId => $oDeliverySet) {
         // loading delivery list to check if some of them fits
         $aDeliveries = $this->_getList($oUser, $sDelCountry, $sDeliverySetId);
         $blDelFound = false;
         foreach ($aDeliveries as $sDeliveryId => $oDelivery) {
             // skipping that was checked and didn't fit before
             if (in_array($sDeliveryId, $aSkipDeliveries)) {
                 continue;
             }
             $aSkipDeliveries[] = $sDeliveryId;
             if ($oDelivery->isForBasket($oBasket)) {
                 // delivery fits conditions
                 $this->_aDeliveries[$sDeliveryId] = $aDeliveries[$sDeliveryId];
                 $blDelFound = true;
                 // unsetting from unfitting list
                 array_pop($aSkipDeliveries);
                 // maybe checked "Stop processing after first match" ?
                 if ($oDelivery->oxdelivery__oxfinalize->value) {
                     break;
                 }
             }
         }
         // found deliveryset and deliveries that fits
         if ($blDelFound) {
             if ($this->_blCollectFittingDeliveriesSets) {
                 // collect only deliveries sets that fits deliveries
                 $aFittingDelSets[$sDeliverySetId] = $oDeliverySet;
             } else {
                 // return collected fitting deliveries
                 oxSession::setVar('sShipSet', $sDeliverySetId);
                 return $this->_aDeliveries;
             }
         }
     }
     //return deliveries sets if found
     if ($this->_blCollectFittingDeliveriesSets && count($aFittingDelSets)) {
         //reseting getting delivery sets list instead of delivieries before return
         $this->_blCollectFittingDeliveriesSets = false;
         //reset cache and list
         $this->setUser(null);
         $this->clear();
         return $aFittingDelSets;
     }
     // nothing what fits was found
     return array();
 }
 /**
  * Returns oxDeliverySetList instance
  *
  * @return oxDeliverySetList
  */
 static function getInstance()
 {
     if (defined('OXID_PHP_UNIT')) {
         if (($oClassMod = modInstances::getMod(__CLASS__)) && is_object($oClassMod)) {
             return $oClassMod;
         } else {
             $inst = oxNew('oxDeliverySetList');
             modInstances::addMod(__CLASS__, $inst);
             return $inst;
         }
     }
     if (!isset(self::$_instance)) {
         // allow modules
         self::$_instance = oxNew('oxDeliverySetList');
     }
     return self::$_instance;
 }