[dw-free] Shop: Fractional currency values show incorrectly
[commit: http://hg.dwscoalition.org/dw-free/rev/ba33322ecc17]
http://bugs.dwscoalition.org/show_bug.cgi?id=2044
Fix shop prices to show two decimal places.
Patch by
gchick.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2044
Fix shop prices to show two decimal places.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/Widget/ShopCart.pm
- cgi-bin/LJ/Widget/ShopItemOptions.pm
-------------------------------------------------------------------------------- diff -r 65b551625bf1 -r ba33322ecc17 cgi-bin/LJ/Widget/ShopCart.pm --- a/cgi-bin/LJ/Widget/ShopCart.pm Tue Nov 10 04:35:41 2009 +0000 +++ b/cgi-bin/LJ/Widget/ShopCart.pm Tue Nov 10 05:03:48 2009 +0000 @@ -69,7 +69,7 @@ sub render_body { $ret .= "<td>" . $item->t_html( admin => $opts{admin} ) . "</td>"; $ret .= "<td>" . ( $item->anonymous || !LJ::isu( $from_u ) ? $class->ml( 'widget.shopcart.anonymous' ) : $from_u->ljuser_display ) . "</td>"; $ret .= "<td>" . ( $item->random ? 'Y' : 'N' ) . "</td>" if $opts{admin}; - $ret .= "<td>\$" . $item->cost . " USD</td>"; + $ret .= "<td>\$" . sprintf( "%.2f" , $item->cost ) . " USD</td>"; if ( $opts{admin} ) { $ret .= "<td>"; if ( $item->t_email ) { diff -r 65b551625bf1 -r ba33322ecc17 cgi-bin/LJ/Widget/ShopItemOptions.pm --- a/cgi-bin/LJ/Widget/ShopItemOptions.pm Tue Nov 10 04:35:41 2009 +0000 +++ b/cgi-bin/LJ/Widget/ShopItemOptions.pm Tue Nov 10 05:03:48 2009 +0000 @@ -57,8 +57,8 @@ sub render_body { foreach my $month_value ( sort { $b <=> $a } @month_values ) { my $full_item = $given_item . $month_value; if ( ref $LJ::SHOP{$full_item} eq 'ARRAY' ) { - my $price_string = $class->ml( "widget.shopitemoptions.price.$full_item", { price => "\$$LJ::SHOP{$full_item}->[0] USD" } ); - $price_string = $class->ml( 'widget.shopitemoptions.price', { num => $month_value, price => "\$$LJ::SHOP{$full_item}->[0] USD" } ) + my $price_string = $class->ml( "widget.shopitemoptions.price.$full_item", { price => "\$".sprintf( "%.2f" , $LJ::SHOP{$full_item}->[0] )." USD" } ); + $price_string = $class->ml( 'widget.shopitemoptions.price', { num => $month_value, price => "\$".sprintf( "%.2f" , $LJ::SHOP{$full_item}->[0] )." USD" } ) if $price_string eq 'ShopItemOptions'; $ret .= $class->html_check( --------------------------------------------------------------------------------