View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003982 | OXID eShop (all versions) | 1.02. Price calculations (discounts, coupons, additional costs etc.) | public | 2012-05-03 15:40 | 2012-12-07 15:07 |
Reporter | manuel.reiss | Assigned To | |||
Priority | high | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 4.5.9 revision 43186 | ||||
Fixed in Version | 4.7.1 / 5.0.1 revision 52468 | ||||
Summary | 0003982: forced basket-calculation - calculateBasket(true) - messes up discount calculation | ||||
Description | By calling calculateBasket(true) you might assume that all previous basket calculations are wiped and recalculated. Unfortunately some calculations depend on _blUpdateNeeded-flag and are not affected by the $blForceUpdate flag. Therefore oxbasket::getBasketSummary() called in oxdiscount::isForBasket() does not reset itself and stacks up its values, resulting e.g. in a huge dArticleDiscountablePrice, which messes up the discount-calculation. | ||||
Steps To Reproduce | create following discounts: discount 1: price-range: 0 - 100€ discount 2: price-range: 100 - 99999€ add to basket::render() (or any other view) oxSession::getInstance()->getBasket()->calculateBasket(true); create a shopping cart < 100€ but > 50€ and call basket view. Due to the summed up values in basketSummary, the applied discount will be discount 2. | ||||
Additional Information | As long as you know, that setting _blUpdateNeeded = true by calling oxbasket::onUpdate() is crucial for a clean recalculation, this behaviour will not affect you. But by referring to docs: @param bool $blForceUpdate set this parameter to TRUE to force basket recalculation IMO this can be classified as a bug. | ||||
Tags | Discount | ||||
Theme | Both | ||||
Browser | All | ||||
PHP Version | any | ||||
Database Version | any | ||||
|
@Developers: I cannot reproduce this case according to description (by creating discounts and checking which one is applied in the basket). But: 1. The ranges of discounts written above are incorrect: a) first discount from "0" - is incorrect, because then it discount is applied on all product prices instantly (not only in basket). That's separate feature of discount logics. So If you want discount applied only in basket, the price should be specified as "From: 0,01" or so. b) the mid range of both discounts is 100 EUR. The range for 2nd discount then should be 100,01, because at the price =100 EUR is not clear which discount should be applied. 2. But please check the mentioned problems from the source code side, to be sure, that there is no issue with that. |
|
Maybe to sum up the whole issue: method: oxbasket::getBasketSummary() if ( $this->_blUpdateNeeded || $this->_aBasketSummary === null ) { this condition is not valid if basket-calculation is called with its blForceUpdate flag = true, because this flag does not set the _blUpdateNeeded-Flag = true. As a consequence, the basketSummary does not reset itself but sums up all the values from basket-contents to its current values. Since discount calculation relies on the basketSummary, those calculations will be incorrect unless a "proper" forced basket-recalculation with _blUpdateNeeded=true flag (achieved via oxbasket::onUpdate()) Proposal: oxbasket::calculateBasket with $blForceUpdate = true should also call oxbasket::onUpdate() |
|
fixed |