PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, June 29, 2022

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

 June 29, 2022     php, smarty, whmcs, whmcs-invoice-template     No comments   

Issue

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>


Answered By - wesamly
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing