[ic] Adding variables

Brian Kosick interchange-users@interchange.redhat.com
Thu Sep 6 16:00:01 2001


At 02:22 PM 9/6/01 -0500, you wrote:
>I am attempting to add two variable on my checkout page and don't seem to be
>getting it right.
>
>I found a thread that had some relevance to this at:
>http://developer2.akopia.com/archive/interchange-users/1998-old/1040.html
>
>There is some code there that adds two variables
>         [set name="ReceiptTotal" interpolate=1][[calc][scratch
>         DeliveryCharge]+[total-cost][/calc]][/set]
>
>I did something very similiar to this:
>
><snip>
>         <TD ALIGN=RIGHT><font face="sans-serif">
>                       [set total_shipping]0[/set]
>                 [item-list]
>                                 [seti total_shipping][calc]
>                                 [scratch total_shipping] + ([item-field 
> shipping] *
>[item-quantity])
>                                 [/calc][/seti]
>                 [/item-list]
>
>                 [currency][scratch total_shipping][/currency]
>         </TD>
></TR>
><TR>
>         <TD ALIGN=RIGHT width="350"><font face="sans-serif">TOTAL: 
> </font></TD>
>
>         [set cart_total][calc][scratch 
> total_shipping]+[subtotal][/calc][/set]
>
>         <TD ALIGN=RIGHT><font face="sans-serif">[currency][scratch
>cart_total][/currency]</TD>
>
>When I do the calc on cart_total I end up with zero. I followed the example
>exactly, I thought. Does someone see something I don't or am I going about
>this wrong?
>
>Any help would be appreciated.
>Chad
>
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>             ____
>   |  | |\ |  ||   Chad M. Wittrock (Chad.Wittrock@uni.edu)
>   \__/ | \| _||_  University of Northern Iowa
>
>_______________________________________________
>interchange-users mailing list
>interchange-users@interchange.redhat.com
>http://interchange.redhat.com/mailman/listinfo/interchange-users

I ran into something similar about a month ago, I believe that it was 
caused by IC formatting certain fields with [currency]  Here's a bit of my 
code that I used to get around it.

[seti tmpdiscountsubtotal][subtotal noformat=1][/seti]
[perl arg=scratch]
   $_ = $Safe{'scratch'}{'tmpsubtotal'} - 
$Safe{'scratch'}{'tmpdiscountsubtotal'};
   $Safe{'scratch'}{'subtotaldiscount'} = $_;
   return '';
[/perl]
[currency][scratch subtotaldiscount][/currency]

note the "noformat" attribute to strip the currency format off the 
numbers.  And I also tried all sorts of variations with using the IC tags, 
but found that in the end, the only way I was able to get it working right 
(IE The way I wanted) was by using the perl style syntax in the page.



Brian Kosick
Web Programmer
New Age Consulting Service, Inc.
216-619-2000
briank@nacs.net