View Issue Details

IDProjectCategoryView StatusLast Update
0005841OXID eShop (all versions)1.02. Price calculations (discounts, coupons, additional costs etc.)public2014-08-01 08:29
Reportereuroxid 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionduplicate 
Product Version 
Target VersionFixed in Version 
Summary0005841: oxvoucher__oxcalculateonec still allows multiple calculations
DescriptionIf you set a voucherseries to be valid with only specific articles, and set them to be calculated only once, the voucher value can still get reduced multiple times.
Steps To ReproduceBackend:
- Make a voucher series with an absolute value of e.g. 10€
- assign some articles
- set all "usable with" options to NO
- check the "calculate once" box.

Frontend:
- Add 2 distinct articles
- Insert voucher code
- See 20€ reduced
Additional InformationReason:
-------

If the voucherseries has assigned articles, the voucher value is calculated by oxvoucher::_getProductDiscoutValue().

This is the code:


        foreach ( $aBasketItems as $aBasketItem ) {

            $oDiscountPrice->setPrice($aBasketItem['discount']);
            $oProductPrice->setPrice($aBasketItem['price']);

            // Individual voucher is not multiplied by article amount
            if (!$oSerie->oxvoucherseries__oxcalculateonce->value) {
                $oDiscountPrice->multiply($aBasketItem['amount']);
                $oProductPrice->multiply($aBasketItem['amount']);
            }

            $oVoucherPrice->add($oDiscountPrice->getBruttoPrice());
            $oProductTotal->add($oProductPrice->getBruttoPrice());

        }

As you can see, calculateonce makes sure that the vouched doesn´t get applied multiple times if you buy the same article with a 1+ amount. But it does not stop the calculation for every single distinct article.

*********
Solution:
*********

Right before closing the foreach loop, add these lines:

// Be sure that an absolute, once-to-be calculated voucher only applies for the first article
if ($oSerie->oxvoucherseries__oxcalculateonce->value
&& 'absolute' ==$oSerie->oxvoucherseries__oxcalculateonce->value) {
    break;
}
TagsNo tags attached.
ThemeAzure
BrowserAll
PHP Versionany
MySQL Versionany

Relationships

duplicate of 0005162 resolvedLinas Kukulskis Coupon calculation is not correkt, when articles are assigned and 

Activities

cesnauskast

2014-08-01 08:29

administrator   ~0010058

Closing this issue as duplicate of 0005162.