MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: [mv] Displaying Discounts



On 16 Dec, System Administrator wrote:
> ******    message to minivend-users from System Administrator <agree@godzone.net.nz>     ******
> 
> I have been trying to solve the 'buy 3 get 1 free' discount and have
> managed to get it to work ( sort of :-)
> 
> Now I want to be able to display the discount on the entire order in
> the shopping cart, the receipt and order etc.  I have included below
> what I have done but I am having a lot of trouble with the fact that
> the various tags return currency rather than numbers and then when I
> try to convert my result to currency I get '.00'.
> 
> In the item-list to display the items I have the following;
>    </td><td [var TABLEFG] valign=top align=right>
>       [item-subtotal]
>       [calc]
>          $MySubTotal += ( substr( '[item-price]', 1 ) * [item-quantity] );
>          return( '' );
>       [/calc]
>    </td>
> 
> And at the bottom of the table I have;
> [calc]
>    my( $SubTotal ) = substr( '[subtotal]', 1 );
>    my( $OrderDiscount ) = $MySubTotal - $SubTotal;
>    if ( $OrderDiscount ) {
>       return( qq{
> <tr>
>    <td __HEADERBG__ colspan=4 align=right valign=center>
>       <font color="__HEADERTEXT__">
>       <b>[L]Discount[/L]</b>
>       </font>
>    </td><td [var TABLEFG] align=right valign=center>
>       $OrderDiscount
>    </td>
> </tr>} );
>    } else {
>       return('');
>    }
> [/calc]
> 
> This produces a 5 in the cell, which is the correct amount. If I use
> [currency]$OrderDiscount[/currency] I get .00 instead of $5.00 which
> is what I want.
> 
> Surely there must be a better way to do this.

I am not sure, but if you use [subtotal] you get a string like "$5.00".
Try [subtotal noformat=1]. For example:

my( $SubTotal ) = '[subtotal noformat=1]';

Regards,

Joachim

Hint:
a) 
#!/usr/bin/perl				#!/usr/bin/perl	
$a = " DM 5,00";			$a = "5.00";
$b = " DM 1,00";			$b = "1.00";
$c = $a - $b;				$c = $a - $b;
print "a = : " . $a . "\n";		print "a = : " . $a . "\n";
print "b = : " . $b . "\n";		print "b = : " . $b . "\n";
print "c = : " . $c . "\n";		print "c = : " . $c . "\n";

output :				output :
a = :  DM 5,00				a = : 5.00
b = :  DM 1,00				b = : 1.00
c = : 0					c = : 4


-- 
Hans-Joachim Leidinger
buch online                 jojo@buchonline.net
Munscheidstr. 14            FAX: +49 209 1971449
45886 Gelsenkirchen         FAX: 0209 1671449



Search for: Match: Format: Sort by: