Wir nutzen es wie von dir beschrieben. Allerdings arbeiten die geposteten Dateien auf Basis von Auswahllisten. Um damit Varianten abzudecken, müsste noch eine Kleinigkeit geändert werden. Mit dem Debugger sollte es eigentlich kein größeres Problem sein.
Dazu müssen 3 Klassen überladen werden.
myarticle.php
<?php
class myArticle extends oxArticle
{
// ----------------------------------------------------------------------------
// Stephen, 31.01.2009, $dSumAmount added
// ----------------------------------------------------------------------------
public function getBasePrice( $dAmount = 1, $dSumAmount = 0 )
{
// override this function if you want e.g. different prices
// for diff. usergroups.
// Performance
$myConfig = $this->getConfig();
if( !$myConfig->getConfigParam( 'bl_perfLoadPrice' ) || !$this->_blLoadPrice )
return;
// GroupPrice or DB price ajusted by AmountPrice
if ($dSumAmount == 0)
{
$dPrice = $this->_getAmountPrice( $dAmount );
}
else
{
$dPrice = $this->_getAmountPrice( $dSumAmount );
}
return $dPrice;
}
// ------------------------------------------------------------------------------
// Stephen, 31.01.2009
// $dSumAmount added
// ------------------------------------------------------------------------------
public function getBasketPrice( $dAmount, $aSelList, $oBasket, $dSumAmount = 0 )
{
$oUser = $oBasket->getBasketUser();
$this->setArticleUser($oUser);
$oBasketPrice = oxNew( 'oxPrice' );
// get base price
// ------------------------------------------------------------------------------
// Stephen, 31.01.2009
// $dSumAmount added
// ------------------------------------------------------------------------------
$dBasePrice = $this->getBasePrice( $dAmount, $dSumAmount );
// applying select list price
$this->_modifySelectListPrice( $dBasePrice, $aSelList );
// setting price
$oBasketPrice->setPrice( $dBasePrice );
// apply VAT
$this->_applyVat( $oBasketPrice, oxNew('oxVatSelector')->getBasketItemVat( $this, $oBasket ) );
// apply currency
$this->_applyCurrency( $oBasketPrice );
// apply discounts
if ( !$this->skipDiscounts() ) {
// apply general discounts
$this->_applyDiscounts( $oBasketPrice, oxDiscountList::getInstance()->getArticleDiscounts( $this, $oUser ) );
}
// returning final price object
return $oBasketPrice;
}
// -------------------------------------------------------------------------------
// Stephen, 31.05.2008
// Return article number
// -------------------------------------------------------------------------------
public function getArticleNumber()
{
if (isset($this->oxarticles__oxartnum->rawValue))
{
return $this->oxarticles__oxartnum->rawValue;
}
elseif (isset($this->oxarticles__oxartnum->value))
{
return $this->oxarticles__oxartnum->value;
}
}
// -------------------------------------------------------------------------------
}
mybasket.php
<?php
class myBasket extends oxBasket
{
// ---------------------------------------------------------------------
// Stephen, 31.01.2008, calculate total amount of a basket item
// ---------------------------------------------------------------------
protected function _calcSumAmount($oxartnum)
{
$dSumAmount = 0;
foreach ( $this->_aBasketContents as $oBasketItem )
{
if ($oBasketItem->getArticleNumber() == $oxartnum)
{
$dSumAmount += $oBasketItem->getAmount();
}
}
return $dSumAmount;
}
/**
* Iterates through basket items and calculates its prices and discounts
*
* @return null
*/
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
// resetting
$this->_aItemDiscounts = array();
$this->_oProductsPriceList = oxNew( 'oxpricelist' );
$this->_oDiscountProductsPriceList = oxNew( 'oxpricelist' );
$this->_oNotDiscountedProductsPriceList = oxNew( 'oxpricelist' );
foreach ( $this->_aBasketContents as $oBasketItem ) {
$this->_iProductsCnt++;
$this->_dItemsCnt += $oBasketItem->getAmount();
$this->_dWeight += $oBasketItem->getWeight();
if ( !$oBasketItem->isDiscountArticle() && ( $oArticle = $oBasketItem->getArticle() ) ) {
$dSumAmount = $this->_calcSumAmount($oBasketItem->getArticleNumber());
$oBasketPrice = $oArticle->getBasketPrice( $oBasketItem->getAmount(), $oBasketItem->getSelList(), $this, $dSumAmount );
$oBasketItem->setPrice( $oBasketPrice );
//P adding product price
$this->_oProductsPriceList->addToPriceList( $oBasketItem->getPrice() );
$oBasketPrice->setBruttoPriceMode();
if ( !$oArticle->skipDiscounts() ) {
// apply basket type discounts
$aItemDiscounts = $oArticle->applyBasketDiscounts( $oBasketPrice, oxDiscountList::getInstance()->getBasketItemDiscounts( $oArticle, $this, $this->getBasketUser() ), $oBasketItem->getAmount() );
if ( is_array($this->_aItemDiscounts) && is_array($aItemDiscounts) ) {
$this->_aItemDiscounts = $this->_mergeDiscounts( $this->_aItemDiscounts, $aItemDiscounts);
}
} else {
$oBasketItem->setSkipDiscounts( true );
$this->setSkipDiscounts( true );
}
$oBasketPrice->multiply( $oBasketItem->getAmount() );
//P collect discount values for basket items which are discountable
if ( !$oArticle->skipDiscounts() ) {
$this->_oDiscountProductsPriceList->addToPriceList( $oBasketPrice );
} else {
$this->_oNotDiscountedProductsPriceList->addToPriceList( $oBasketPrice );
$oBasketItem->setSkipDiscounts( true );
$this->setSkipDiscounts( true );
}
} elseif ( $oBasketItem->isBundle() ) {
// if bundles price is set to zero
$oPrice = oxNew( "oxprice");
$oBasketItem->setPrice( $oPrice );
}
}
}
}
mybasketitem.php
<?php
class myBasketItem extends oxBasketItem
{
// -------------------------------------------------------------------
// Stephen, 31.01.2009
// Return article number
// -------------------------------------------------------------------
public function getArticleNumber()
{
return $this->_oArticle->getArticleNumber();
}
// -------------------------------------------------------------------
}
Testen kannst du z.B. bei diesem Artikel: http://www.andro-shop.com/Proteine-Eiweiss/Whey/ESN-Designer-Whey-1000g-Standbeutel.html mit verschiedenen Geschmacksrichtungen.
Liebe Grüße
Carolin