MiniVend Akopia Services

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

Re: [mv] Displaying Discounts



I think you are mixing up strings and numbers in your scripts.
Use the noformat=1 argument to get number results and not substr().
Check the docs for details. There are also many posts in this mailing
list's archive that cover this issue.
Chris
 
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.
> --
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> 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
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> -
> To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
> email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
> Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: