magento currency magento头部增加币种切换选择

magento currency

magento头部增加币种切换选择

默认magento 货币选择切换是显示在左边 有时候我们需要让其显示在头部

Step 1. Create a new file app/design/frontend/default/Your_Theme/template/directory/currency-top.phtml

<?php if($this->getCurrencyCount()>1): ?>
<div class="block block-currency-top">
<strong><span><?php echo $this->__('Select Your Currency') ?></span></strong>
<select name="currency" title="<?php echo $this->__('Select Your Currency') ?>" onchange="setLocation(this.value)">
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
<option value="<?php echo $this->getSwitchCurrencyUrl($_code) ?>"<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected="selected"<?php endif; ?>>
<?php echo $_name ?> - <?php echo $_code ?>
</option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>

Step 2. Now add the below given line of code inside header block in app/design/frontend/default/Your_Theme/layout/page.xml

<block type="directory/currency" name="currency_top" template="directory/currency-top.phtml"/>

Step 3. Add the below given line in app/design/frontend/default/Your_Theme/template/page/html/header.phtml

<?php echo $this->getChildHtml('currency_top'); ?>

以上来源点这里

修改magento货币符号和货币符号的位置
用magento建多语言店面的时候往往要添加相应的货币,有时候想修改货币符号为自己想要的格式,怎么修改呢?这里提供一个简单方法:
1.首先要在configuration General => Locale options => Locale检查你的语言环境是什么
2.如果你的locale 是默认的选项“English (United States)”,就打开lib/Zend/Locale/Data/目录下的en.xml 编辑
3.例如你要修改日元符号为”円”(默认是显示”¥”),就搜索“JPY”大约3245行找到下面代码,把”¥”修改成”円” 保存

<currency type="JPY">
<displayname>Japanese Yen</displayname>
<displayname count="one">Japanese yen</displayname>
<displayname count="other">Japanese yen</displayname>
<symbol>¥</symbol>
</currency>

4.保存上传后清楚后台缓存System –> Cache Management
5.到这里刷新前台也许还没变,要删掉var下的cache缓存目录 /var/cache
6.刷新前台OK了
还有一个问题,修改后前台显示的是”円25,522.64 ” ,我想把符号放在后面怎么修改呢?方法很简单,还是编辑en.xml ,搜索”” 大约2597行找到下面代码

<currencyformatlength>
<currencyformat>
<pattern>¤#,##0.00;(¤#,##0.00)</pattern>
</currencyformat>
</currencyformatlength>

将¤#,##0.00;(¤#,##0.00)改成#,##0.00 ¤;(#,##0.00 ¤) 即可
¤为货币符号位置
以上来源点这里

相同介绍还有

改变Magento Currency布局

Custom Magento Currency Switcher in Header

How to add Currency selector to Magento’s header

将顶部币种换位图片
则currency.phtml 内容修改为

<?php if($this->getCurrencyCount()>1): ?>
<div class="currency" style="text-align: right; position: relative; top: 26px; right: 18px;">
<?php foreach ($this->getCurrencies() as $_code => $_name): ?> <a href="<?php echo $this->getSwitchCurrencyUrl($_code) ?>" onclick="setLocation(this.value);">
<img src="/images/<?php echo $_code ?>.png" title="<?php echo $_name ?> - <?php echo $_code ?>"/>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>

来自Add flag icons to your Magento site header to switch currency

上一篇:javascript与java的不同之处


下一篇:css超出内容以省略号显示