我有Magento 1.9.0.1运行与英镑(£)作为基础和默认显示货币,欧元(€)作为允许的货币。
如果用户选择以欧元付款,则网站正常运行,除非用户使用PayPal以自己的货币付款,则订单确认邮件有错误。在我的测试中,我用欧元结账,但我的PayPal账户用英镑结账。
购物车的商品价格和小总价以欧元显示,但带有£符号。小计,交付& &;合计均以欧元显示,并带有正确的€符号。
下面的例子显示了大致价格的基本表示:
Items Quantity Item Price Sub Total
--- --- --- ---
Product 1 £150.00 £150.00 <<-- These £'s should be €'s
-----------------------------------------------
Sub Total: €150.00
Delivery: €0.00
Total: €150.00
Grand Total to be Charged: £100.00
我试着去追踪它,但是我不确定哪里出了问题,而且测试起来简直是噩梦。邮件调用:
(Mage_Checkout_Helper_Data) $this->helper('checkout')->formatPrice(...);
,
(Mage_Core_Model_Store) $this->getQuote()->getStore()->formatPrice($price);
它最终找到了Zend货币方法,但我不知道货币符号在哪里丢失了。
此问题仅发生在PayPal付款时,而不是直接通过网站通过CC付款时。
谁能给我指个正确的方向?由于确认邮件中,任何地方都不应该有对$this->helper('checkout')->formatPrice(...)
的调用。如果是这种情况,则订单电子邮件使用结帐项模板而不是自己的模板,这可能是由于未完全实现自定义产品类型或主题中的错误造成的。
订单总数显示正确的货币,因为总计块使用订单的formatPrice()
方法,该方法将订单的货币考虑在内:
$this->getOrder()->formatPrice($total->getValue());
单项模板也使用$_order->formatPrice(...)
。但是根据产品类型的不同,使用了不同的模板。这是默认模板。
每种产品类型的块和模板在sales.xml
中定义,addItemRender
操作:
<sales_email_order_items>
<block type="sales/order_email_items" name="items" template="email/order/items.phtml">
<action method="addItemRender"><type>default</type><block>sales/order_email_items_order_default</block><template>email/order/items/order/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>sales/order_email_items_order_grouped</block><template>email/order/items/order/default.phtml</template></action>
<block type="sales/order_totals" name="order_totals" template="sales/order/totals.phtml">
<action method="setLabelProperties"><value>colspan="3" align="right" style="padding:3px 9px"</value></action>
<action method="setValueProperties"><value>align="right" style="padding:3px 9px"</value></action>
<block type="tax/sales_order_tax" name="tax" template="tax/order/tax.phtml">
<action method="setIsPlaneMode"><value>1</value></action>
</block>
</block>
</block>
<block type="core/text_list" name="additional.product.info" />
</sales_email_order_items>
添加产品类型的模块必须在那里注册自己的渲染器,如bundle.xml
所示:
<sales_email_order_items>
<reference name="items">
<action method="addItemRender"><type>bundle</type><block>bundle/sales_order_items_renderer</block><template>bundle/email/order/items/order/default.phtml</template></action>
</reference>
</sales_email_order_items>
如果没有定义,则默认呈现器是来自结帐的呈现器,其中不使用订单模型本身,只使用单个项目(没有附加货币信息)。在这里,价格格式化是由checkout helper完成的,checkout helper没有关于订单的信息,所以它使用当前选择的存储货币。
为什么只有像PayPal这样的在线支付才会出现这个问题?因为在其他方法中,使用"下订单"按钮立即创建订单确认邮件,当前选择的存储货币仍然与订单货币相同。但在PayPal的回调请求中,此上下文丢失,将使用默认货币代替。
你需要做什么?
- 在布局XML文件中搜索
<sales_email_order_items>
布局句柄,查看默认的项目渲染器是否正确注册 - 确保任何自定义产品类型也注册了它们的渲染器
- 检查项目渲染器使用的模板。也许这是你的主题中的一个bug,你只需要将
$this->_helper('checkout')->formatPrice()
替换为$_order->formatPrice()
。
这似乎是字符集货币错误。您需要通过搜索特定的电子邮件模板代码来应用charset utf-8
您可以在System->Manage currency -> symbols中更改货币符号