Sophia Posted January 4, 2011 Share Posted January 4, 2011 I'm not sure where to post this question... it has more to do with JavaScript then WHMCS. A little background: a while ago I purchased the custom mod to compare plans. I set it up, but now decided to break down my pricing in monthly sections, offering a discount the longer people subscribe. Anyway... what I really wish to do, is break down the pricing in the compare template, but I don't think it is possible. If I look in the list of smarty tags, and found this [plan1_rawmonthly] => 1.50 [plan1_rawquarterly] => -1.00 [plan1_rawsemiannual] => -1.00 [plan1_rawannual] => 15.00 [plan1_rawbiennial] => 27.60 [plan1_rawtriennial] => 36.00 Now, here is my real question at last: is it possible to wrap these in some JavaScript, so that I can divide the rawannual by 12, rawbiennial by 24, etc? I am an absolute JavaScript rookie, so if anybody would be so kind to explain how to do that, I'd be eternally grateful I tried <script language="javascript"> function {$plan1_rawannual}/12 </script> But obviously it's not THAT simple Thanks! 0 Quote Link to comment Share on other sites More sharing options...
Sophia Posted January 4, 2011 Author Share Posted January 4, 2011 Whoo hooo, I found my own answer <script language="javascript"> document.write({$plan1_rawannual}/12); </script> It's that simple 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted January 4, 2011 Share Posted January 4, 2011 You can also do it in the smarty template {math equation="x / y" x=$plan1_rawannual y=12} 0 Quote Link to comment Share on other sites More sharing options...
Sophia Posted January 4, 2011 Author Share Posted January 4, 2011 (edited) Thanks! After a lot of thinking, sweating and Googling (my best friend), I found this solution: <script language="javascript"> document.write( '<b>{$currency.prefix} ' + ({$plan1_rawtriennial}/36).toFixed(2) + '</b><br />' ); document.write( ' ' + ({$plan1_rawbiennial}/24).toFixed(2) + '<br />' ); document.write( ' ' + ({$plan1_rawannual}/12).toFixed(2) + '<br />' ); document.write( ' ' + ({$plan1_rawmonthly}).toFixed(2) + ' ' ); </script> But yours seems so much more simple and neat Just a question, which Smarty template would that be? The compare plans one or...? Edited January 4, 2011 by Sophia 0 Quote Link to comment Share on other sites More sharing options...
Sophia Posted January 5, 2011 Author Share Posted January 5, 2011 You can also do it in the smarty template Unfortunately, my neat little javascript argues with another element on my page, so, would you kindly tell me which smarty template to edit? I found the includes/smarty folder, but didn't quite see the list of elements. Thanks again for your help 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted January 5, 2011 Share Posted January 5, 2011 You would use that within the tpl file that you are working on that you put the javascript in. {math equation="x / y" x=$plan1_rawannual y=12} this code will actually output the value for you. 0 Quote Link to comment Share on other sites More sharing options...
Sophia Posted January 5, 2011 Author Share Posted January 5, 2011 I seriously love you That works great! If I may bug you one last time... how do I make sure it actually displays the amount with 2 digits (1.00 instead of 1 and 2.00 instead of 2.000003)? In JavaScript I found the command is toFixed but I don't know how to do it here... thanks again Sparky! 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted January 5, 2011 Share Posted January 5, 2011 You could do that like this {math equation="x / y" x=$plan1_rawannual y=12 format="%.2f"} for your reference http://www.smarty.net/docsv2/en/language.function.math.tpl 0 Quote Link to comment Share on other sites More sharing options...
Sophia Posted January 5, 2011 Author Share Posted January 5, 2011 Thanks ever so much Sparky, and I now realize I bought those two mods from YOU Money well spent and thanks for the additional help! 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted January 5, 2011 Share Posted January 5, 2011 No problem... your comparison page is looking good. You can also use the math function to change the sizes from MB to GB Also check your facebook like images... they are breaking your SSL 0 Quote Link to comment Share on other sites More sharing options...
Sophia Posted January 5, 2011 Author Share Posted January 5, 2011 Thanks... I'm testing on a different page though, try /comparetest.php I'll use your tip to convert to GB, good stuff, and thanks for the Facebook warning 0 Quote Link to comment Share on other sites More sharing options...
SilverNodashi Posted October 24, 2011 Share Posted October 24, 2011 Would you guys mind telling me which file to edit, specifically for the "Modern" cart, to make these changes? 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.