问题描述
我有一个转销商计划,但货币只有英镑,美元,日元和欧元。
我可以设置自己的价格,但是我想在用户页面上将货币显示为泰铢。
产品和价格在红宝石上被动态拉动,我可以使用代码,但我无法将货币更改为泰铢。
我的问题是可以使用脚本,以便在页面加载时用我想要的货币替换当前值。
即,如果我的价值为$ 1.00,脚本将用$替换$,并将1.00乘以33,这样用户将看到?33而不是$ 1.00。
这是我可以编辑的代码示例:
<script type='text/javascript'>
// <[CDATA[
// Populate some hashes in the js context:
var dual_core = new Array();
<% dual_core.each do |dc| %>
dual_core["<%= dc.specific_type %>-<%= dc.base_renewal_period %>"] = new Array();
dual_core["<%= dc.specific_type %>-<%= dc.base_renewal_period %>"]["specific_type"] = "<%= dc.specific_type %>";
dual_core["<%= dc.specific_type %>-<%= dc.base_renewal_period %>"]["base_renewal_period"] = "<%= dc.base_renewal_period %>";
dual_core["<%= dc.specific_type %>-<%= dc.base_renewal_period %>"]["unit_price"] = "<%= dc.unit_price %>";
dual_core["<%= dc.specific_type %>-<%= dc.base_renewal_period %>"]["quoted_unit_price"] = "<%= billing.price(dc.unit_price) %>";
dual_core["<%= dc.specific_type %>-<%= dc.base_renewal_period %>"]["display_price"] = "<%= billing.price(dc.unit_price, :use_tax_prefs) %>";
<% end %>
var quad_core = new Array();
<% quad_core.each do |qc| %>
quad_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"] = new Array();
quad_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["specific_type"] = "<%= qc.specific_type %>";
quad_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["base_renewal_period"] = "<%= qc.base_renewal_period %>";
quad_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["unit_price"] = "<%= qc.unit_price %>";
quad_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["quoted_unit_price"] = "<%= billing.price(qc.unit_price) %>";
quad_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["display_price"] = "<%= billing.price(qc.unit_price, :use_tax_prefs) %>";
<% end %>
var quad_core_bd = new Array();
<% quad_core_bd.each do |qc| %>
quad_core_bd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"] = new Array();
quad_core_bd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["specific_type"] = "<%= qc.specific_type %>";
quad_core_bd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["base_renewal_period"] = "<%= qc.base_renewal_period %>";
quad_core_bd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["unit_price"] = "<%= qc.unit_price %>";
quad_core_bd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["quoted_unit_price"] = "<%= billing.price(qc.unit_price) %>";
quad_core_bd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["display_price"] = "<%= billing.price(qc.unit_price, :use_tax_prefs) %>";
<% end %>
var octo_core = new Array();
<% octo_core.each do |qc| %>
octo_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"] = new Array();
octo_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["specific_type"] = "<%= qc.specific_type %>";
octo_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["base_renewal_period"] = "<%= qc.base_renewal_period %>";
octo_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["unit_price"] = "<%= qc.unit_price %>";
octo_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["quoted_unit_price"] = "<%= billing.price(qc.unit_price) %>";
octo_core["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["display_price"] = "<%= billing.price(qc.unit_price, :use_tax_prefs) %>";
<% end %>
var octo_core_fd = new Array();
<% octo_core_fd.each do |qc| %>
octo_core_fd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"] = new Array();
octo_core_fd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["specific_type"] = "<%= qc.specific_type %>";
octo_core_fd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["base_renewal_period"] = "<%= qc.base_renewal_period %>";
octo_core_fd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["unit_price"] = "<%= qc.unit_price %>";
octo_core_fd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["quoted_unit_price"] = "<%= billing.price(qc.unit_price) %>";
octo_core_fd["<%= qc.specific_type %>-<%= qc.base_renewal_period %>"]["display_price"] = "<%= billing.price(qc.unit_price, :use_tax_prefs) %>";
<% end %>
var cpanel = new Array();
<% cpanel.each do |cp| %>
cpanel["<%= cp.specific_type %>-<%= cp.base_renewal_period %>"] = new Array();
cpanel["<%= cp.specific_type %>-<%= cp.base_renewal_period %>"]["specific_type"] = "<%= cp.specific_type %>";
cpanel["<%= cp.specific_type %>-<%= cp.base_renewal_period %>"]["base_renewal_period"] = "<%= cp.base_renewal_period %>";
cpanel["<%= cp.specific_type %>-<%= cp.base_renewal_period %>"]["quoted_unit_price"] = "<%= billing.price(cp.unit_price) %>";
cpanel["<%= cp.specific_type %>-<%= cp.base_renewal_period %>"]["display_price"] = "<%= billing.price(cp.unit_price, :use_tax_prefs) %>";
<% end %>
var backup = new Array();
<% backup.each do |bk| %>
backup["<%= bk.specific_type %>-<%= bk.base_renewal_period %>"] = new Array();
backup["<%= bk.specific_type %>-<%= bk.base_renewal_period %>"]["specific_type"] = "<%= bk.specific_type %>";
backup["<%= bk.specific_type %>-<%= bk.base_renewal_period %>"]["base_renewal_period"] = "<%= bk.base_renewal_period %>";
backup["<%= bk.specific_type %>-<%= bk.base_renewal_period %>"]["quoted_unit_price"] = "<%= billing.price(bk.unit_price) %>";
backup["<%= bk.specific_type %>-<%= bk.base_renewal_period %>"]["display_price"] = "<%= billing.price(bk.unit_price, :use_tax_prefs) %>";
<% end %>
// ]]>
</script>
<!--
<script type='text/javascript' src='<%= url_prefix %>ds.js'></script>
-->
<!-- include the template ds-js.rhtml -->
<% included_content_result = include_common_template("ds-js.rhtml", "@included_content_out_js") %>
<%= included_content_result %>
<div class='container' id='t-dedicated-servers'>
<h2 id='effective-title'>Dedicated Servers</h2>
<p>
Our range of Dedicated Servers provide either Dual or Quad core processors, include
unlimited bandwidth and are perfect for busy websites or hosting multiple websites on one machine.
</p>
<p>
Choose from Linux CentOS or Windows Web Server 2008. All servers are setup with
your choice of operating system in about 30 minutes by our automated system.
</p>
<% @os_to_name = { "linux" => "Linux (CentOS)", "windows" => "Windows Server 2008 Web Edition", "windows_se" => "Windows Server 2008 Standard Edition"} %>
<form accept-charset='utf-8' method='post' action='basket' id='order-form'>
<% if no_upsell? %><input type='hidden' name='no-upsell' value='1'/><% end %>
<table style='border: 1'>
<tbody>
<tr>
<% if dual_core_for_sale %>
<% @core_type = "2c" %>
<!-- include the template ds-common.rhtml -->
<% included_content_result = include_common_template("ds-common.rhtml", "@included_content_out_two") %>
<%= included_content_result %>
<% end %>
<% if quad_core_for_sale %>
<% if os_list['4c'].size > 0 %>
<% @core_type = "4c" %>
<!-- include the template ds-common.rhtml -->
<% included_content_result = include_common_template("ds-common.rhtml", "@included_content_out_four") %>
<%= included_content_result %>
<% end # os_list[4c].size > 0 %>
<!-- Quad core large disk -->
<% if quad_core_large_disk_for_sale %>
<% @core_type = "4c_bd" %>
<!-- include the template ds-common.rhtml -->
<% included_content_result = include_common_template("ds-common.rhtml", "@included_content_out_four_b") %>
<%= included_content_result %>
<% end # quad_core_large_disk_for_sale %>
<% end %>
</tr>
<tr>
<% if octo_core_for_sale %>
<% if os_list['8c_bd'].size > 0 %>
<% @core_type = "8c_bd" %>
<!-- include the template ds-common.rhtml -->
<% included_content_result = include_common_template("ds-common.rhtml", "@included_content_out_eight") %>
<%= included_content_result %>
<% end # os_list['8c'].size > 0 %>
<!-- Octo (2xQuad) core fast disk -->
<% if octo_core_fd_for_sale %>
<% @core_type = "8c_fd" %>
<!-- include the template ds-common.rhtml -->
<% included_content_result = include_common_template("ds-common.rhtml", "@included_content_out_eight_b") %>
<%= included_content_result %>
<% end # octo_core_fd_for_sale %>
<% end %>
</tr>
</tbody>
</table>
<% if free_products.size > 0 %>
<p>
If you order a Dedicated Server you will be entitled to one free registration for the minimum period of a domain of one of the following types:<br />
<% free_products.each_key do |fp| %>
<%= free_products[fp] %><br />
<% end %>
</p>
<% end %>
<p><input type='submit' value='Add to Basket' onclick='javascript: if(!get_selected_period()) { alert("Please choose a price and payment frequency");return false; } else { return true; };'/></p>
</form>
<% unless basket.nil? or basket.empty? or no_upsell? %>
<p><a href='basket?add-no-product=ds'>No thank you, please continue with my order ....</a></p>
<% end %>
<% if not billing.tax_applies? %>
<% elsif billing.include_tax? %>
<p>* Includes <%= billing.tax_name %></p>
<% else %>
<p>* Excluding <%= billing.tax_name %></p>
<% end %>
</div>
<%
=begin advice %>
This section is completely ignored and can safely be removed.
<%
=end advice %>
我希望我已经对它进行了足够的解释,以使您理解。
在此先感谢您阅读或帮助我。
1楼
我认为您应该使用此来转换货币。 可以使用服务器上的服务器端脚本或上的JavaScript 来完成此操作。