Example #1
0
 function getBasketSummary()
 {
     if ($this->oBasketSummaryCache) {
         return $this->oBasketSummaryCache;
     } else {
         return parent::getBasketSummary();
     }
 }
Example #2
0
 /**
  * Tests if total amount or price (price priority) of articles that can be applied to current discount fits to discount configuration
  *
  * @param oxbasket $oBasket basket
  *
  * @return bool
  */
 public function isForBasketAmount($oBasket)
 {
     $dAmount = 0;
     $aBasketItems = $oBasket->getContents();
     foreach ($aBasketItems as $oBasketItem) {
         $oBasketArticle = $oBasketItem->getArticle(false);
         $blForBasketItem = false;
         if ($this->oxdiscount__oxaddsumtype->value != 'itm') {
             $blForBasketItem = $this->isForBasketItem($oBasketArticle);
         } else {
             $blForBasketItem = $this->isForBundleItem($oBasketArticle);
         }
         if ($blForBasketItem) {
             $dRate = $oBasket->getBasketCurrency()->rate;
             if ($this->oxdiscount__oxprice->value) {
                 if ($oPrice = $oBasketArticle->getPrice()) {
                     $dAmount += $oPrice->getPrice() * $oBasketItem->getAmount() / $dRate;
                 }
             } elseif ($this->oxdiscount__oxamount->value) {
                 $dAmount += $oBasketItem->getAmount();
             }
         }
     }
     return $this->isForAmount($dAmount);
 }
Example #3
0
 /**
  * Checks if delivery set used for current order is available and active.
  * Throws exception if not available
  *
  * @param oxbasket $oBasket basket object
  *
  * @return int
  */
 public function validateDelivery($oBasket)
 {
     if ($oBasket->getPaymentId() == 'oxidpaypal') {
         $sShippingId = $oBasket->getShippingId();
         $dBasketPrice = $oBasket->getPrice()->getBruttoPrice();
         $oUser = oxNew('oxUser');
         if (!$oUser->loadUserPayPalUser()) {
             $oUser = $this->getUser();
         }
         $iValidState = null;
         if (!$this->_isPayPalPaymentValid($oUser, $dBasketPrice, $sShippingId)) {
             $iValidState = self::ORDER_STATE_INVALIDDELIVERY;
         }
     } else {
         $iValidState = parent::validateDelivery($oBasket);
     }
     return $iValidState;
 }
 /**
  * Returns base basket price for payment cost calculations. Price depends on
  * payment setup (payment administration)
  *
  * @param oxbasket $oBasket oxbasket object
  *
  * @return double
  */
 public function getBaseBasketPriceForPaymentCostCalc($oBasket)
 {
     $dBasketPrice = 0;
     $iRules = $this->oxpayments__oxaddsumrules->value;
     // products brutto price
     if (!$iRules || $iRules & self::PAYMENT_ADDSUMRULE_ALLGOODS) {
         $dBasketPrice += $oBasket->getProductsPrice()->getBruttoSum();
     }
     // discounts
     if ((!$iRules || $iRules & self::PAYMENT_ADDSUMRULE_DISCOUNTS) && ($oCosts = $oBasket->getTotalDiscount())) {
         $dBasketPrice -= $oCosts->getBruttoPrice();
     }
     // vouchers
     if (!$iRules || $iRules & self::PAYMENT_ADDSUMRULE_VOUCHERS) {
         $dBasketPrice -= $oBasket->getVoucherDiscValue();
     }
     // delivery
     if ((!$iRules || $iRules & self::PAYMENT_ADDSUMRULE_SHIPCOSTS) && ($oCosts = $oBasket->getCosts('oxdelivery'))) {
         $dBasketPrice += $oCosts->getBruttoPrice();
     }
     // wrapping
     if ($iRules & self::PAYMENT_ADDSUMRULE_GIFTS && ($oCosts = $oBasket->getCosts('oxwrapping'))) {
         $dBasketPrice += $oCosts->getBruttoPrice();
     }
     return $dBasketPrice;
 }
Example #5
0
 /**
  * Checks if payment used for current order is available and active.
  * Throws exception if not available
  *
  * @param oxbasket $oBasket basket object
  *
  * @return null
  */
 public function validatePayment($oBasket)
 {
     // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
     $masterDb = oxDb::getMaster();
     $oPayment = oxNew("oxpayment");
     $sTable = $oPayment->getViewName();
     $sQ = "select 1 from {$sTable} where {$sTable}.oxid=" . $masterDb->quote($oBasket->getPaymentId()) . " and " . $oPayment->getSqlActiveSnippet();
     if (!$masterDb->getOne($sQ)) {
         return self::ORDER_STATE_INVALIDPAYMENT;
     }
 }
Example #6
0
 /**
  * Checks if payment used for current order is available and active.
  * Throws exception if not available
  *
  * @param oxbasket $oBasket basket object
  *
  * @return null
  */
 public function validatePayment($oBasket)
 {
     $oDb = oxDb::getDb();
     $oPayment = oxNew("oxpayment");
     $sTable = $oPayment->getViewName();
     $sQ = "select 1 from {$sTable} where {$sTable}.oxid=" . $oDb->quote($oBasket->getPaymentId()) . " and " . $oPayment->getSqlActiveSnippet();
     if (!$oDb->getOne($sQ, false, false)) {
         return self::ORDER_STATE_INVALIDPAYMENT;
     }
 }
 /**
  * Checks if delivery fits for current basket
  *
  * @param oxbasket $oBasket shop basket
  *
  * @return bool
  */
 public function isForBasket($oBasket)
 {
     // amount for conditional check
     $blHasArticles = $this->hasArticles();
     $blHasCategories = $this->hasCategories();
     $blUse = true;
     $iAmount = 0;
     $blForBasket = false;
     // category & article check
     if ($blHasCategories || $blHasArticles) {
         $blUse = false;
         $aDeliveryArticles = $this->getArticles();
         $aDeliveryCategories = $this->getCategories();
         foreach ($oBasket->getContents() as $oContent) {
             //V FS#1954 - load delivery for variants from parent article
             $oArticle = $oContent->getArticle(false);
             $sProductId = $oArticle->getProductId();
             $sParentId = $oArticle->getProductParentId();
             if ($blHasArticles && (in_array($sProductId, $aDeliveryArticles) || $sParentId && in_array($sParentId, $aDeliveryArticles))) {
                 $blUse = true;
                 $iArtAmount = $this->getDeliveryAmount($oContent);
                 if ($this->oxdelivery__oxfixed->value > 0) {
                     if ($this->_isForArticle($oContent, $iArtAmount)) {
                         $blForBasket = true;
                     }
                 }
                 if (!$blForBasket) {
                     $iAmount += $iArtAmount;
                 }
             } elseif ($blHasCategories) {
                 if (isset(self::$_aProductList[$sProductId])) {
                     $oProduct = self::$_aProductList[$sProductId];
                 } else {
                     $oProduct = oxNew('oxarticle');
                     $oProduct->setSkipAssign(true);
                     if (!$oProduct->load($sProductId)) {
                         continue;
                     }
                     $oProduct->setId($sProductId);
                     self::$_aProductList[$sProductId] = $oProduct;
                 }
                 foreach ($aDeliveryCategories as $sCatId) {
                     if ($oProduct->inCategory($sCatId)) {
                         $blUse = true;
                         $iArtAmount = $this->getDeliveryAmount($oContent);
                         if ($this->oxdelivery__oxfixed->value > 0) {
                             if ($this->_isForArticle($oContent, $iArtAmount)) {
                                 $blForBasket = true;
                             }
                         }
                         break;
                     }
                 }
                 if (!$blForBasket) {
                     $iAmount += $iArtAmount;
                 }
             }
         }
     } else {
         // regular amounts check
         foreach ($oBasket->getContents() as $oContent) {
             $iArtAmount = $this->getDeliveryAmount($oContent);
             if ($this->oxdelivery__oxfixed->value > 0) {
                 if ($this->_isForArticle($oContent, $iArtAmount)) {
                     $blForBasket = true;
                 }
             }
             if (!$blForBasket) {
                 $iAmount += $iArtAmount;
             }
         }
     }
     //#M1130: Single article in Basket, checked as free shipping, is not buyable (step 3 no payments found)
     if (!$blForBasket && $blUse && ($this->_checkDeliveryAmount($iAmount) || $this->_blFreeShipping)) {
         $blForBasket = true;
     }
     return $blForBasket;
 }