susanto
susanto

Reputation: 57

how to show the product price in template with currency (WHMCS)

I need, when user currency change this time automatically price change the related with the active current.

<h4 class="h5">Starting At<strong>
{if  $currency=2 } // currency id = 2//
 Rs 1.19                                        
 {else}
 $ 1.19
{/if}
<small>/m</small></strong></h4>

I try this code. but not work. :( please help me

Upvotes: 1

Views: 1598

Answers (2)

Faizan Khan
Faizan Khan

Reputation: 16

Use this 100% working

 {if  $activeCurrency.id > 1 }
    $0.60
    {else}
    ₹45
    {/if}

Upvotes: -1

wesamly
wesamly

Reputation: 1584

WHMCS doesn't load current currency on all pages, i think only cart pages.

So you need to add a currency selection form to allow client to switch between currencies.

<form action="" method="post">
    <label for="currency_sel">Currency:</label>
    <select name="currency" id="currency_sel" class="form-control" onchange="submit();">
        <option value="1" {if $smarty.post.currency eq '1'}selected{/if}>$</option>
        <option value="2" {if $smarty.post.currency eq '2'}selected{/if}>Rs</option>
    </select>   

</form>

The selected currency will be available with the variable $smarty.post.currency Update your code as following:

<h4 class="h5">Starting At<strong>
{if  $smarty.post.currency eq '2' } 
 Rs 1.19                                        
 {else}
 $ 1.19
{/if}
<small>/m</small></strong></h4>

Upvotes: 2

Related Questions