View Issue Details

IDProjectCategoryView StatusLast Update
0004680OXID eShop (all versions)1.02. Price calculations (discounts, coupons, additional costs etc.)public2012-12-07 15:07
Reporteraggrosoft Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.6.5 revision 49955 
Fixed in Version4.6.6 revision 54646 
Summary0004680: Discount recalculation fails on basket refresh
DescriptionIf you are working with a single basket item and a list of discounts the calcuation might fail. The discount is calculated in the first place, calculations after that are skipped.
Steps To Reproduce- Create product with price 10€
- Create 3 discount rules:

6% from 100 to 199 €
9% from 200 to 299 €
12% from 300 to 99999 €

- Be sure the rules are assigned to the products category or directly to the product
- Put product into cart

- Set amount to 15
- Rule 6% works

- Set amount to 25
- Rule 9% is ignored

- Set amount to 36
- Rule 12% is ignored

It does work with multiple different items in cart! I tracked the issue down, it works with a little patch. The problem is that in oxDiscountList::getBasketItemDiscounts calling $this->_getList( $oUser ) does NOT reset the iterator. The foreach will not go through all items and will stop after the first one.
Additional InformationUsing $this->_getList( $oUser )->getArray() is a workaround for the issue (which is done in getBasketDiscounts already):

public function getBasketItemDiscounts( $oArticle, $oBasket, $oUser = null )
    {
        $aList = array();
        $oList = $this->_getList( $oUser )->getArray();
        foreach ( $oList as $oDiscount ) {
            if ( $oDiscount->isForBasketItem( $oArticle ) && $oDiscount->isForBasketAmount( $oBasket ) ) {
                $aList[$oDiscount->getId()] = $oDiscount;
            }
        }
        
        return $aList;
    }
TagsDiscount
ThemeBoth
BrowserAll
PHP Versionany
Database Versionany

Activities

Linas Kukulskis

2012-11-09 10:07

reporter   ~0007790

added discount array reset