/** * Executes parent method parent::render(), creates oxorder and * oxuserpayment objects, passes data to Smarty engine and returns * name of template file "order_main.tpl". * * @return string */ public function render() { parent::render(); $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId(); if ($soxId != "-1" && isset($soxId)) { // load object $oOrder = oxNew("oxorder"); $oOrder->load($soxId); // paid ? if ($oOrder->oxorder__oxpaid->value != "0000-00-00 00:00:00") { $oOrder->blIsPaid = true; $oOrder->oxorder__oxpaid = new oxField(oxUtilsDate::getInstance()->formatDBDate($oOrder->oxorder__oxpaid->value)); } $this->_aViewData["edit"] = $oOrder; $this->_aViewData["paymentType"] = $oOrder->getPaymentType(); $this->_aViewData["oShipSet"] = $oOrder->getShippingSetList(); if ($oOrder->oxorder__oxdeltype->value) { // order user $oUser = oxNew('oxuser'); $oUser->load($oOrder->oxorder__oxuserid->value); // order sum in default currency $dPrice = $oOrder->oxorder__oxtotalbrutsum->value / $oOrder->oxorder__oxcurrate->value; $this->_aViewData["oPayments"] = oxPaymentList::getInstance()->getPaymentList($oOrder->oxorder__oxdeltype->value, $dPrice, $oUser); } // any voucher used ? $this->_aViewData["aVouchers"] = $oOrder->getVoucherNrList(); } $this->_aViewData["sNowValue"] = date("Y-m-d H:i:s", oxUtilsDate::getInstance()->getTime()); return "order_main.tpl"; }
/** * 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; }
/** * Loads deliveryset data, checks if it has payments assigned. If active delivery set id * is passed - checks if it can be used, if not - takes first ship set id from list which * fits. For active ship set collects payment list info. Retuns array containing: * 1. all ship sets that has payment (array) * 2. active ship set id (string) * 3. payment list for active ship set (array) * * @param string $sShipSet current ship set id (can be null if not set yet) * @param oxuser $oUser active user * @param double $oBasket basket object * * @return array */ public function getDeliverySetData($sShipSet, $oUser, $oBasket) { $sActShipSet = null; $aActSets = array(); $aActPaymentList = array(); if (!$oUser) { return; } $this->_getList($oUser, $oUser->getActiveCountry()); // if there are no shipsets we dont need to load payments if ($this->count()) { // one selected ? if ($sShipSet && !isset($this->_aArray[$sShipSet])) { $sShipSet = null; } $oPayList = oxPaymentList::getInstance(); $oDelList = oxDeliveryList::getInstance(); $oCur = $this->getConfig()->getActShopCurrencyObject(); $dBasketPrice = $oBasket->getPriceForPayment() / $oCur->rate; // checking if these ship sets available (number of possible payment methods > 0) foreach ($this as $sShipSetId => $oShipSet) { $aPaymentList = $oPayList->getPaymentList($sShipSetId, $dBasketPrice, $oUser); if (count($aPaymentList)) { // now checking for deliveries if ($oDelList->hasDeliveries($oBasket, $oUser, $oUser->getActiveCountry(), $sShipSetId)) { $aActSets[$sShipSetId] = $oShipSet; if (!$sShipSet || $sShipSetId == $sShipSet) { $sActShipSet = $sShipSet = $sShipSetId; $aActPaymentList = $aPaymentList; $oShipSet->blSelected = true; } } } } } return array($aActSets, $sActShipSet, $aActPaymentList); }