kimaweb Posted December 11, 2006 Share Posted December 11, 2006 Hi everybody. So I've been searching this forum for a loooong time now. I could really use some help. I wrote with matt earliery today and he said that it is posible to add you own php variable in the tpl files. So i did this in viewinvoice to get it to show and ekstra field, but.. it dosnt work. Dos anyone have an idea of what i am doing wrong? First i added this: {php} $moms = $total/5; {/php} then where i wanted to show the amount (20% of the total amount) i added this: {php} echo $moms; {/php} but it shows 0 Anyone whom can help me please Sincerely Matt 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted December 11, 2006 Share Posted December 11, 2006 echo $total and see what you get. Most likely it will be 0 what exactly are you trying to do? if total is a smarty variable, then just do {math equation="x / 5" x=$total} 0 Quote Link to comment Share on other sites More sharing options...
kimaweb Posted December 11, 2006 Author Share Posted December 11, 2006 Yes, 0 i was.. but how can i fix it? there must be a way? 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted December 11, 2006 Share Posted December 11, 2006 heck, even {$total/5} might even work 0 Quote Link to comment Share on other sites More sharing options...
kimaweb Posted December 11, 2006 Author Share Posted December 11, 2006 Im really sad now. That didnt work. It showed 0, but.. at least it did show something... More ideas? 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted December 11, 2006 Share Posted December 11, 2006 both of my suggestions didnt work? 0 Quote Link to comment Share on other sites More sharing options...
kimaweb Posted December 11, 2006 Author Share Posted December 11, 2006 None of them worked. a smarty what? It is just the viewinvoice.tlp i am trying to and and ekstra fielnd in. Here some of the code, so you can see what im doing: <tr><td id="invoiceitemsheading"><div align="right">{$LANG.invoicescredit}</div></td><td id="invoiceitemsheading" align="center">{$credit}</td></tr> <tr><td id="invoiceitemsheading"><div align="right">Moms </div></td> {php} $moms = $total/5; {/php} <td id="invoiceitemsheading" align="center">{php} echo $moms; {/php}</td> </tr> 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted December 11, 2006 Share Posted December 11, 2006 right, dont try doing it with {php} tags, remove that completely and just try: {$total/5} or {math equation="x / 5" x=$total} 0 Quote Link to comment Share on other sites More sharing options...
kimaweb Posted December 11, 2006 Author Share Posted December 11, 2006 With {math equation="x / 5" x=$total} it shows nothing. With {$total/5} it shows 0 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted December 11, 2006 Share Posted December 11, 2006 what is your total normally? 0 Quote Link to comment Share on other sites More sharing options...
kimaweb Posted December 11, 2006 Author Share Posted December 11, 2006 Well, depends on what people are ordering. But on this invoice the total amount is 99 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted December 11, 2006 Share Posted December 11, 2006 there were a couple hurdles. The main one was that the $ was causing issues with the math. Here is a work around and does exactly what you wanted. {php} $total = $this->get_template_vars('total'); $newtotal = sprintf("%01.2f", ((str_replace('$','',$total)) / 5)); echo '$'.$newtotal; {/php} 0 Quote Link to comment Share on other sites More sharing options...
kimaweb Posted December 11, 2006 Author Share Posted December 11, 2006 did you test that? coz it dosnt work here...? 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted December 11, 2006 Share Posted December 11, 2006 yep, works perfectly for me. 0 Quote Link to comment Share on other sites More sharing options...
kimaweb Posted December 11, 2006 Author Share Posted December 11, 2006 Maybe you have msn messenger? wanna help me? it would really be so nice.. 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted December 11, 2006 Share Posted December 11, 2006 lol, scroll up, i have 3 different messengers listed above. btw, i have/had no need for this code, i did it just for you out of the kindness of my heart. Merry Christmas =P 0 Quote Link to comment Share on other sites More sharing options...
kimaweb Posted December 11, 2006 Author Share Posted December 11, 2006 hehe, i did add you, but no ones there. I know, you do this to be nice, and im pleased! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.