I found this trying to work out how to display user points instead of $ values for products. I know of the userpoints_ubercart module but it only changes the prices on individual product pages, not product lists and when you buy with points you get a confirmation and invoice with the $ value listed, which is irrelevant on my site.
So I tried making a custom price_handler and override the options so that it uses the word Points instead of $ and so on. It doesn't work.
The reason is line 258:
$handlers['options'] += $hook['options'];</options>
In php adding arrays with a + will not overwrite the contents of duplicated keys in the left array in the equation. i.e. only new keys in $hook['options'] will be added to the defaults.
The correct line should be:
<code>$handlers['options'] = $hook['options'] + $handlers['options'];
Comments
Comment #1
mr.j commentedI wish drupal.org would let us edit our own nodes. Trying again...
Line 258 in uc_price.inc:
$handlers['options'] += $hook['options'];In php adding arrays with a + will not overwrite the contents of duplicated keys in the left array in the equation. i.e. only new keys in $hook['options'] will be added to the defaults.
The correct line should be:
$handlers['options'] = $hook['options'] + $handlers['options'];Comment #2
beifler commentedI'm also in need of having this issue resolved. @Maintainers thanks in advance for your attention. ;)
Comment #3
tr commented@beifler: How about a review then? Does the proposed fix work for you? Does it break any core or contributed modules that may rely on the old behavior?
Moving to active since we don't have a patch yet.
Comment #4
mr.j commentedFair but utterly pedantic call, I didn't create a patch file for a one liner (might have been on a machine which didn't have diff ... don't know it was so long ago).
So here it is ... drumroll please ...
Comment #5
tr commentedMy main point was that we need a review. I was hoping @beifler would test your fix because he stated he had the same problem.
Comment #6
mr.j commentedNo problem. I'll be sure to post a patch file from now on.
Comment #7
longwaveThe same fix was committed by Island Usurper a couple of weeks ago in #610916: merging of associative arrays broken
Comment #8
beifler commentedThanks guys! Sorry TR - I don't get emails when topics are updated, making it hard to keep track of topics. I'd be happy to test, but it looks like this is complete.