dlobo/org.civicrm.module.cividiscount — pull request #50 by eileenmcnaughton (2014-06-05 10:24:50+00:00)
Title: Fix discount calculation code not showing

Most of the time I spent on this was actually on thinking my fix wasn't working when it was because I was doing tests / looking for symptoms that were not going to happen because of these 3 things. The first 2 I think are non-regressive bugs whereas the third is a feature change that may need some thought

1) if there are multiple valid discount codes per event they don't all work
- I'd previously added the comment " // this seems to incorrectly set to only the last discount but it seems not to matter in the way it is used" (https://github.com/dlobo/org.civicrm.module.cividiscount/blob/master/cividiscount.php#L388 ") because I couldn't understand why only one code was being assigned - this means that at this point https://github.com/dlobo/org.civicrm.module.cividiscount/blob/master/cividiscount.php#L215 it will only pass the latest discount

2) If you are using Text price values the label to the right does not update - making it appear the price field has not updated. The descriptive label does indicate the discount & it is reflected in the calculation (Option values are fine)

3) The commit (not actually mine) that makes the price field discount work also means that you HAVE to apply a price field discount for it to work. I think it makes sense for it to default to all items rather than none if none are selected. (this is std Civi UI but we didn't do this in CiviDiscount due to outcome of our previous discussions - I can't actually recall the details)
I suspect that this line is the place to look at this
$priceFields = isset($discount['pricesets']) ? $discount['pricesets'] : array();