/** * Sets $this->oPrice * * @param object $oPrice price * * @return null */ public function setPrice($oPrice) { $this->_oPrice = oxNew('oxprice'); $this->_oPrice->setBruttoPriceMode(); $this->_oPrice->setVat($oPrice->getVAT()); $this->_oPrice->addPrice($oPrice); $this->_oPrice->multiply($this->getAmount()); $this->_oUnitPrice = oxNew('oxprice'); $this->_oUnitPrice->setBruttoPriceMode(); $this->_oUnitPrice->setVat($oPrice->getVAT()); $this->_oUnitPrice->addPrice($oPrice); }
/** * Executes all needed functions to calculate basket price and other needed * info * * @param bool $blForceUpdate set this parameter to TRUE to force basket recalculation * * @return null */ public function calculateBasket($blForceUpdate = false) { if (!$this->isEnabled()) { return; } if (!$this->_blUpdateNeeded && !$blForceUpdate) { return; } $this->_aCosts = array(); $this->_oPrice = oxNew('oxprice'); $this->_oPrice->setBruttoPriceMode(); // 1. saving basket to the database $this->_save(); // 2. remove all bundles $this->_clearBundles(); // 3. generate bundle items $this->_addBundles(); // reserve active basket if ($this->getConfig()->getConfigParam('blPsBasketReservationEnabled')) { $this->getSession()->getBasketReservations()->reserveBasket($this); } // 4. calculating item prices $this->_calcItemsPrice(); // 5. calculating/applying discounts $this->_calcBasketDiscount(); // 6. calculating basket total discount $this->_calcBasketTotalDiscount(); // 7. check for vouchers $this->_calcVoucherDiscount(); // 8. applies all discounts to pricelist $this->_applyDiscounts(); // 9. calculating additional costs: // 9.1: delivery $this->setCost('oxdelivery', $this->_calcDeliveryCost()); // 9.2: adding wrapping costs $this->setCost('oxwrapping', $this->_calcBasketWrapping()); // 9.3: adding payment cost $this->setCost('oxpayment', $this->_calcPaymentCost()); // 9.4: adding TS protection cost $this->setCost('oxtsprotection', $this->_calcTsProtectionCost()); // 10. calculate total price $this->_calcTotalPrice(); // 11. setting deprecated values $this->_setDeprecatedValues(); // 12.setting to up-to-date status $this->afterUpdate(); }
/** * testing calculation of discount of brutto price * * @return null */ public function testGetDiscountedProductsBruttoPrice() { $oProdPrice = new oxPrice(1199); $oProdPrice->setBruttoPriceMode(); $oProdPriceList = oxNew('oxPriceList'); $oProdPriceList->addToPriceList($oProdPrice); $oTotalDiscount = new oxPrice(100); $oTotalDiscount->setBruttoPriceMode(); $oVoucherDiscount = new oxPrice(100); $oVoucherDiscount->setBruttoPriceMode(); $oBasket = $this->getMock("oxbasket", array("getDiscountProductsPrice", "getTotalDiscount", "getVoucherDiscount")); $oBasket->expects($this->once())->method('getDiscountProductsPrice')->will($this->returnValue($oProdPriceList)); $oBasket->expects($this->once())->method('getTotalDiscount')->will($this->returnValue($oTotalDiscount)); $oBasket->expects($this->once())->method('getVoucherDiscount')->will($this->returnValue($oVoucherDiscount)); $this->assertEquals(999, $oBasket->getDiscountedProductsBruttoPrice()); }