Jump to content

Display Current Currency Variable


Gx-

Recommended Posts

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated