phpsmartywhmcswhmcs-invoice-template

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


Solution

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