Gx- Posted March 21, 2012 Share Posted March 21, 2012 So I have completely customized homepage.tpl - and I have a form that works, and allows you to choose USD, CAD, and AUD currencies. I know the form works... as the session is updated, etc as i can see on the cart that the prices have changed... however I want to display the current pricing... i can do the basic php as far as display, modifying, accessing, etc of variables... but I just cant seem to get the value from $_SESSION, $_POST or $_GET. the form is posting "currency", but it seems that variable is lost as nothing is displayed when I call it. Yet the form works so it must have been valid/changed previously. Any idea how i can display the value of "currency"? i might just be tired but nothing seems obvious. ive spent an hour trying various things, googling, and searching these forums. Most ive gotten seem to say $_SESSION['currency'] was valid at some point... but by the time it gets to the tpl file i believe its been destroyed... 0 Quote Link to comment Share on other sites More sharing options...
Digvijay Posted March 21, 2012 Share Posted March 21, 2012 Hi Have you started the session before using it. It can be a reason as well. You have to use session_start() before using $_SESSION. Another thing that you can do is printing session. You can do print_r($_SESSION) and check all the values stored in the session. If you post the code here that will clear the problem more. 0 Quote Link to comment Share on other sites More sharing options...
Gx- Posted March 21, 2012 Author Share Posted March 21, 2012 <form method="post" action="index.php"> (Change Currency: <select name="currency" onchange="submit()"> <option value="3">AUD</option> <option value="2">CAD</option> <option value="1" selected>USD</option> </select> <input type="submit" value="Go" />) </form> Really simple script I get no output from print_r... so i suspect that the session variable is destroyed after use... but there must be a way to access it... the encrypted WHMCS code seems to have no issues... if i use the form, whmcs gets updated... i just want to know if another variable is created that i can use, before the session variable is destroyed. and it doesnt matter if i use session_start()... the above form works either way. As i see it... i should be able to use either to obtain this information... but i get nothing. echo $_SESSION['currency']; echo $_POST['currency']; but i believe there must be a variable declared earlier, before the tpl file is loaded, that i can access? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted March 21, 2012 Share Posted March 21, 2012 Are you in a cart page? If you're on a cart page, you can reference the {$currency} smarty variable. Its an array of details regarding the currency. {$currency} Array (6) id => 1 code => GBP prefix => £ suffix => empty format => 1 rate => 1.00000 0 Quote Link to comment Share on other sites More sharing options...
Gx- Posted March 22, 2012 Author Share Posted March 22, 2012 Hm... I think that was a great idea... however it doesnt seem to be working. I can accesss {$currencies} but thats just a list of all available. for example when I use {$currency.id} i get null/nothing im not entirely sure if this page index.php/homepage.tpl is considered a cart page... is there anything i can do to initialize such a thing? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted March 22, 2012 Share Posted March 22, 2012 Nah, thats not a cart page, it wont be available. Currency isnt really applicable unless its on a cart page, or you're logged in, so I doubt you're going to find a hack around this. 0 Quote Link to comment Share on other sites More sharing options...
Gx- Posted March 22, 2012 Author Share Posted March 22, 2012 thats a shame... Is there a way for me to run PHP within that template file (homepage.tpl)? im really not familiar with smarty and template coding lol I suppose i could just create my own custom index.php - im really not using anything within the index page that uses the whmcs engine - but if i were to do that, is there a way I could still load/set the whmcs session variables so that I might set the default currency? Do the developer(s) ever answer questions here? they might have a better idea about the backend... short of us just guessing at session code/variables in encrypted code... 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted March 22, 2012 Share Posted March 22, 2012 Yes, you can execute PHP code within templates. simply wrap the PHP code with {php} {/php} tags. The developers do answer questions here on occasion, but its not their first priority. However, I do understand the system quite well, and am fairly certain in what I said. You could also open a support ticket and you'll likely get a response from a developer/support person with an official answer. 0 Quote Link to comment Share on other sites More sharing options...
Gx- Posted March 22, 2012 Author Share Posted March 22, 2012 Awesome... And i didnt mean to imply that i didnt trust your response. I can see you do a lot of module/addon development for the whmcs... but as the core engine is encrypted i just figured a developer might have a definitive answer haha. I think i may open a support ticket simply to answer this once and for all haha ive certainly spent way to much effort on this as it is. Anyways, thanks for the responses... 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.