如何在WHMCS自定义页面上添加货币选择器?

时间:2020-06-30 13:27:42

标签: selector currency whmcs

我试图在显示商品详细信息的自定义页面之一上添加货币选择器。 我想允许访问者从此自定义页面更改默认货币,并相应地查看产品价格。

我已将此代码添加到我的custom.tpl

                                <input type="hidden" name="token" value="{$LANG.go}">
                                <select name="currency" onchange="submit()" class="form-control">
                                    <option value="">Change Currency (A$ AUD)</option>
                                    {foreach from=$currencies item=listcurr}
                                        <option value="{$listcurr.id}"{if $listcurr.id == $currency.id} selected{/if}>{$listcurr.prefix} {$listcurr.code}</option>
                                    {/foreach}
                                </select>
                            </form> ```



But it is not working, every time I select the currency from the dropdown, it refreshes the page. but nothing changes,
please guide what I am doing wrong.

Thanks in advance
Aqsa,

1 个答案:

答案 0 :(得分:0)

您可以执行此操作。您可以将表单更新为以下任何一种形式:

  1. 执行GET请求,并将currency=$id参数添加到URL($idtblcurrencies中货币的ID。

  1. 提交表单时,请处理表单输入,并在会话变量中设置币种:
use WHMCS\Session;

Session::set('currency', $id);

同样,$idtblcurrencies.id相关。

请记住,现有用户无法更改币种,并且不建议在他们进行任何交易后更改其币种,以避免会计/计算问题。

相关问题