namhost Posted August 1, 2019 Share Posted August 1, 2019 (edited) This code works fine on /cart.php {foreach from=$currencies item=currchoice} <li> <a href="{$currentpagelinkback}currency={$currchoice.id}" class="{if $currency.id eq $currchoice.id}active{/if}"> {$currchoice.code} </a> </li> {/foreach} But on /index.php, the "$currency" variable is empty. So this part doesnt work: {if $currency.id eq $currchoice.id}active{/if} Any idea why the "$currency" variable is not active on all pages? And any idea how to add it to all pages? Or is the current currency perhaps stored in session somewhere that I can grab it? Edited August 2, 2019 by WHMCS ChrisD Added code into code boxes 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 1, 2019 Share Posted August 1, 2019 8 minutes ago, namhost said: Any idea why the "$currency" variable is not active on all pages? because it's only available to the cart. 🙂 if a client is logged in, then you can find their currency - but as users cannot change their currency, that's not really relevant to your needs I think. there are GeoIP solutions that can determine where a user is from and set a currency (if they're not logged in)... 9 minutes ago, namhost said: And any idea how to add it to all pages? i'm not sure why you would need to - are you intending to show pricing on a non-cart page ? 17 minutes ago, namhost said: Or is the current currency perhaps stored in session somewhere that I can grab it? only if the user has changed it whilst in the cart - so when they first go to the homepage, a currency will not be set - and it won't be in the session array... and just going to the cart doesn't set one (the cart defaults to using your default currency but it isn't set as such)... whilst in the cart, if they change currencies, then it will added to the session and available on all pages. using the code i've posted previously for adding a currency to the header menu will also change the currency session value.. though that jQuery code could be added to a hook file rather than editing and minifying core files - the template edit to add the currency menu would still be required though. 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.