Jump to content

Showing price in right currency on front-page


rudberg

Recommended Posts

In order to let the user select which currency to view prices with on the whmcs first-page (.tpl-based), I tried the following code, but it doesn't seem currencies will ever change, and they are certainly not written out. I do get a bit confused by having both a tblproducts and a tblpricing table in the db, but assume it's the tblpricing I should be using here.

 

I picked up the "choose currency" code from the /orderform/products.tpl template, but I assume, that can't just be done like that. What would I have to do instead?

 

Code:

<!--Choose currency-->
{if !$loggedin && $currencies}
<form method="post" action="index-beta.php?gid={$smarty.get.gid}">
<p align="right" valign="middle">{$LANG.choosecurrency}: <select name="currency" onchange="submit()">
{foreach from=$currencies item=curr}
<option value="{$curr.id}"{if $curr.id eq $currency.id} selected{/if}>{$curr.code}</option>
{/foreach}</select>
<input type="submit" value="{$LANG.go}" /></p>
</form>
{/if}
<!--End choose currency-->
<!--Print each product-id and pricing for the active currency only in the format: Monthly from - to, Setup from - to-->
{php}
    $query = 'SELECT * FROM tblpricing';
    $result = mysql_query ($query);
    while ($data = @mysql_fetch_array ($result))
       {
$monthly = $data['monthly'];
$biennial = $data['biennial'];
$msetupfee = $data['msetupfee'];
$bsetupfee = $data['bsetupfee'];
$package = $data['id'];

if ($monthly == '0.00') {$monthly = 'FREE';} else {$monthly = $CONFIG['CurrencySymbol'].$monthly;}
if ($biennial == '0.00') {$biennial = 'FREE';} else {$biennial = $CONFIG['CurrencySymbol'].$biennial;}
if ($msetupfee == '0.00') {$msetupfee = 'FREE';} else {$msetupfee = $CONFIG['CurrencySymbol'].$msetupfee;}
if ($bsetupfee == '0.00') {$bsetupfee = 'FREE';} else {$bsetupfee = $CONFIG['CurrencySymbol'].$bsetupfee;}

if($data['hidden'] != "on" )
	{
	echo $package;
	echo " Price: ";
	echo $currencysymbol;
	echo " ";
	echo $biennial;
	echo " – ";
	echo $monthly;
	echo "per month & from FREE – ";
	echo $currencysymbol;
	echo " ";
	echo $msetupfee;
	echo " in setup.";
	echo "<br />"; 
	}
   }
{/php}

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