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'];
CommentFileSizeAuthor
#4 uc_price.inc_.patch297 bytesmr.j

Comments

mr.j’s picture

I 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'];

beifler’s picture

I'm also in need of having this issue resolved. @Maintainers thanks in advance for your attention. ;)

tr’s picture

Status: Needs review » Active

@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.

mr.j’s picture

Status: Active » Needs review
StatusFileSize
new297 bytes

Fair 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 ...

tr’s picture

My main point was that we need a review. I was hoping @beifler would test your fix because he stated he had the same problem.

mr.j’s picture

No problem. I'll be sure to post a patch file from now on.

longwave’s picture

Status: Needs review » Closed (duplicate)

The same fix was committed by Island Usurper a couple of weeks ago in #610916: merging of associative arrays broken

beifler’s picture

Thanks 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.