[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Displaying Discounts
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.
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Glen Eustace, on behalf of
GodZone Internet Services, a division of AGRE Enterprises Limited
P.O. Box 8020, Palmerston North, New Zealand
Ph: +64 6 356 2562, Fax: +64 6 357 0271
http://www.godzone.net.nz, EMail: agree@godzone.net.nz, ICQ: 10397208
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=