Hi,
wenn ich bei Rabatten die von Grenze (Menge oder Preis) bei 1 beginnen lasse,
werden die Rabatte auch im Warenkorb angezeigt (unter “Summe Artikel (brutto)”), jedoch wird der Rabatt anscheinend nicht mehr einzeln auf die Artikel berechnet sondern erst im Warenkorb bei Gesamt. Wenn die von Grenze bei 0 beginnen lasse wird der Rabatt bei den Artikeln berechnet, jedoch wird er nicht mehr im Warenkorb angezeigt.
Gibt es die Möglichkeit beides zu kombinieren? Das heißt das ich auf den Artikel- / Listenseiten und im Warenkorb bei den einzelnen Artikeln den reduzierten Preis noch sehe und im Gesamtbereich alle Rabatte auch nochmal aufgelistet bekomme?
Hallo,
danke für die Information.
Das hatte ich schon befürchtet. Na gut muss ich halt wieder selber dran rumschrauben.
Grüße
Das Problem konnte “gelöst” werden. Zwar ein wenig anders als geplannt, aber folgendes hab ich gemacht:
Ich habe mir eine Zweite Variable an allen benötigten Stellen mit durchgeschleift die die Artikel “Base” Preise (entsprechend der Preisgruppe) benutzt und keine Rabatte/Coupons benötigt. Am Ende kann ich den “Warenkorbpreis” und den “Warenkorbpreis ohne Rabatte” subtrahieren und eventuelle Rabatte/Reduzierungen ausgeben.
Folgende Funktionen wurden in der models/oxbasket.php per Modul überladen:
/**
* Total basket price without discounts
*
* @var oxPrice
*/
protected $_oPriceWithoutDiscount = null;
/**
* Basket netto sum without discounts
*
* @var decimal
*/
protected $_dNettoSumWithoutDiscount = null;
/** without discounts
* Basket brutto sum
*
* @var decimal
*/
protected $_dBruttoSumWithoutDiscount = null;
/**
* Returns basket price without discounts object
*
* @return oxPrice
*/
public function getPriceWithoutDiscount()
{
if (is_null($this->_oPriceWithoutDiscount)) {
$this->setPriceWithoutDiscount(oxNew('oxPrice'));
}
return $this->_oPriceWithoutDiscount;
}
/**
* Set basket total sum price object
*
* @param oxPrice $oPrice Price object
*/
public function setPriceWithoutDiscount($oPrice)
{
$this->_oPriceWithoutDiscount = $oPrice;
}
//P
/**
* Performs final sum calculation and rounding.
*/
protected function _calcTotalPrice()
{
// 1. add products price
$dPrice = $this->_dBruttoSum;
$dPriceWithoutDiscount = $this->_dBruttoSumWithoutDiscount;
$oTotalPrice = oxNew('oxPrice');
$oTotalPrice->setBruttoPriceMode();
$oTotalPrice->setPrice($dPrice);
$oTotalPriceWithoutDiscount = oxNew('oxPrice');
$oTotalPriceWithoutDiscount->setBruttoPriceMode();
$oTotalPriceWithoutDiscount->setPrice($dPriceWithoutDiscount);
// 2. subtract discounts
if ($dPrice && !$this->isCalculationModeNetto()) {
// 2.2 applying basket discounts
$oTotalPrice->subtract($this->_oTotalDiscount->getBruttoPrice());
// 2.3 applying voucher discounts
if ($oVoucherDisc = $this->getVoucherDiscount()) {
$oTotalPrice->subtract($oVoucherDisc->getBruttoPrice());
}
}
// 2.3 add delivery cost
if (isset($this->_aCosts['oxdelivery'])) {
$oTotalPrice->add($this->_aCosts['oxdelivery']->getBruttoPrice());
$oTotalPriceWithoutDiscount->add($this->_aCosts['oxdelivery']->getBruttoPrice());
}
// 2.4 add wrapping price
if (isset($this->_aCosts['oxwrapping'])) {
$oTotalPrice->add($this->_aCosts['oxwrapping']->getBruttoPrice());
$oTotalPriceWithoutDiscount->add($this->_aCosts['oxwrapping']->getBruttoPrice());
}
if (isset($this->_aCosts['oxgiftcard'])) {
$oTotalPrice->add($this->_aCosts['oxgiftcard']->getBruttoPrice());
$oTotalPriceWithoutDiscount->add($this->_aCosts['oxgiftcard']->getBruttoPrice());
}
// 2.5 add payment price
if (isset($this->_aCosts['oxpayment'])) {
$oTotalPrice->add($this->_aCosts['oxpayment']->getBruttoPrice());
$oTotalPriceWithoutDiscount->add($this->_aCosts['oxpayment']->getBruttoPrice());
}
// 2.6 add TS protection price
if (isset($this->_aCosts['oxtsprotection'])) {
$oTotalPrice->add($this->_aCosts['oxtsprotection']->getBruttoPrice());
$oTotalPriceWithoutDiscount->add($this->_aCosts['oxtsprotection']->getBruttoPrice());
}
$this->setPrice($oTotalPrice);
$this->setPriceWithoutDiscount($oTotalPriceWithoutDiscount);
}
/**
* Performs netto price and VATs calculations including discounts and vouchers.
*/
protected function _applyDiscounts()
{
//apply discounts for brutto price
$dDiscountedSum = $this->_getDiscountedProductsSum();
$oUtils = oxRegistry::getUtils();
$dVatSum = 0;
foreach ($this->_aDiscountedVats as $dVat) {
$dVatSum += $oUtils->fRound($dVat, $this->_oCurrency);
}
$oNotDiscounted = $this->getNotDiscountProductsPrice();
if ($this->isCalculationModeNetto()) {
// netto view mode
$this->setNettoSum($this->getProductsPrice()->getSum());
$this->setBruttoSum($oNotDiscounted->getSum(false) + $dDiscountedSum + $dVatSum);
// netto view mode
$this->setNettoSumWithoutDiscount($this->getProductsPriceWithoutDiscount()->getSum());
$this->setBruttoSumWithoutDiscount($oNotDiscounted->getSum(false));
} else {
// brutto view mode
$this->setNettoSum($oNotDiscounted->getSum() + $dDiscountedSum - $dVatSum);
$this->setBruttoSum($this->getProductsPrice()->getSum(false));
// brutto view mode
$this->setNettoSumWithoutDiscount($oNotDiscounted->getSum());
$this->setBruttoSumWithoutDiscount($this->getProductsPriceWithoutDiscount()->getSum(false));
}
}
/**
* Return basket netto sum (in B2B view mode sum include discount)
*
* @return decimal
*/
public function getNettoSumWithoutDiscount()
{
return $this->_dNettoSumWithoutDiscount;
}
/**
* Return basket brutto sum (in B2C view mode sum include discount)
*
* @return decimal
*/
public function getBruttoSumWithoutDiscount()
{
return $this->_dBruttoSumWithoutDiscount;
}
/**
* Set basket netto sum
*
* @param decimal $dNettoSum sum of basket in netto mode
*/
public function setNettoSumWithoutDiscount($dNettoSumWithoutDiscount)
{
$this->_dNettoSumWithoutDiscount = $dNettoSumWithoutDiscount;
}
/**
* Set basket brutto sum
*
* @param decimal $dBruttoSum sum of basket in brutto mode
*/
public function setBruttoSumWithoutDiscount($dBruttoSumWithoutDiscount)
{
$this->_dBruttoSumWithoutDiscount = $dBruttoSumWithoutDiscount;
}
/**
* Iterates through basket items and calculates its prices and discounts
*/
protected function _calcItemsPrice()
{
// resetting
$this->setSkipDiscounts(false);
$this->_iProductsCnt = 0; // count different types
$this->_dItemsCnt = 0; // count of item units
$this->_dWeight = 0; // basket weight
$this->_oProductsPriceList = oxNew('oxpricelist');
$this->_oDiscountProductsPriceList = oxNew('oxpricelist');
$this->_oNotDiscountedProductsPriceList = oxNew('oxpricelist');
$this->_oProductsPriceListWithoutDiscount = oxNew('oxpricelist');
$oDiscountList = oxRegistry::get("oxDiscountList");
foreach ($this->_aBasketContents as $oBasketItem) {
$this->_iProductsCnt++;
$this->_dItemsCnt += $oBasketItem->getAmount();
$this->_dWeight += $oBasketItem->getWeight();
if (!$oBasketItem->isDiscountArticle() && ($oArticle = $oBasketItem->getArticle(true))) {
$oBasketPrice = $oArticle->getBasketPrice($oBasketItem->getAmount(), $oBasketItem->getSelList(), $this);
$oBasketItem->setRegularUnitPrice(clone $oBasketPrice);
if (!$oArticle->skipDiscounts() && $this->canCalcDiscounts()) {
// apply basket type discounts for item
$aDiscounts = $oDiscountList->getBasketItemDiscounts($oArticle, $this, $this->getBasketUser());
reset($aDiscounts);
foreach ($aDiscounts as $oDiscount) {
$oBasketPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
}
$oBasketPrice->calculateDiscount();
} else {
$oBasketItem->setSkipDiscounts(true);
$this->setSkipDiscounts(true);
}
$oBasketItem->setPrice($oBasketPrice);
$this->_oProductsPriceList->addToPriceList($oBasketItem->getPrice());
$priceObject = $oArticle->getBasePriceObject();
$priceObject->multiply($oBasketItem->getAmount());
$this->_oProductsPriceListWithoutDiscount->addToPriceList($priceObject);
//P collect discount values for basket items which are discountable
if (!$oArticle->skipDiscounts()) {
$this->_oDiscountProductsPriceList->addToPriceList($oBasketItem->getPrice());
} else {
$this->_oNotDiscountedProductsPriceList->addToPriceList($oBasketItem->getPrice());
$oBasketItem->setSkipDiscounts(true);
$this->setSkipDiscounts(true);
}
} elseif ($oBasketItem->isBundle()) {
// if bundles price is set to zero
$oPrice = oxNew("oxprice");
$oBasketItem->setPrice($oPrice);
}
}
}
/**
* Returns basket products price list object
*
* @return oxPriceList
*/
public function getProductsPriceWithoutDiscount()
{
if (is_null($this->_oProductsPriceListWithoutDiscount)) {
$this->_oProductsPriceListWithoutDiscount = oxNew('oxPriceList');
}
return $this->_oProductsPriceListWithoutDiscount;
}
Folgende Funktion wurden in der models/oxarticle.php per Modul hinzugefügt:
/**
* Returns getBasePriceObject
*
* @return oxPrice
*/
public function getBasePriceObject()
{
$oPrice = $this->_getPriceObject();
$oPrice->setPrice($this->getBasePrice());
return $oPrice;
}
Dadurch könnte folgendes in der basketcontents.tpl benutzt werden:
[{assign var="one" value=$oxcmp_basket->getPrice()}]
[{assign var="two" value=$oxcmp_basket->getPriceWithoutDiscount()}]
[{math equation="y - x" x=$one->getPrice() y=$two->getPrice() assign=savings}]
[{if $savings}]
<strong>Sie sparen durch Rabatte/Coupons: [{oxprice price=$savings currency=$currency}]</strong>
[{/if}]
Falls jemand Verbesserungsvorschläge hat oder Fehler findet immer her damit.