【问题标题】:how to show the product price in template with currency (WHMCS)如何使用货币(WHMCS)在模板中显示产品价格
【发布时间】:2019-06-08 21:58:30
【问题描述】:

我需要,当用户货币更改时,自动更改与有效电流相关的价格。

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

我试试这个代码。但不工作。 :( 请帮帮我

【问题讨论】:

  • 在WHMCS中您可以添加多种货币,并为每种货币设置产品价格。这就是你想要的吗?
  • 我想,当当前货币=us,us currency id=1,这次显示这个货币价格。 like->

    Starting At {if $currency=1 } // 当前货币 id = 1// $1.19 {else} Rs. 1.19 {/if} /m

  • 如何调用当前货币,并显示当前货币价格。
  • 您正在编辑哪个 tpl 文件?
  • 我创建了一个新的主页 tpl 文件。这个文件叫做 call current currency and show price。

标签: php smarty whmcs whmcs-invoice-template


【解决方案1】:

WHMCS 不会在所有页面上加载当前货币,我认为只有购物车页面。

所以你需要添加一个货币选择表单来允许客户在货币之间切换。

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

所选货币将通过变量$smarty.post.currency 更新您的代码如下:

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

【讨论】:

  • 你能告诉我,如何使用用户活跃的国家代码自动更改货币吗?
  • 这是问题所在,但我可以使用国家/地区 IP 地址吗?
  • 检查这个模块,它可能会有所帮助:modulesgarden.com/products/whmcs/geolocation-hook
【解决方案2】:

使用这个 100% 工作

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-21
    • 1970-01-01
    相关资源
    最近更新 更多