29

I have Magento 1.9.0.1 running with GBP (£) as the base and default display currency, and Euros (€) as an allowed currency.

If the user chooses to checkout in Euros, the site all works except, if they pay by PayPal in their own currency, then the order confirmation email has a mistake. On my test below I checked out in Euros (€) but my PayPal account was using Pounds (£).

The cart's Item Price and Sub Total show in Euros, but with a £ symbol. The Sub Total, Delivery & Total all appear in Euros, with the correct € symbol.

The example below shows a basic representation with approximate prices:

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

I've tried to track it down, but I'm not sure where it goes wrong, and it's a nightmare to test. The email calls:

(Mage_Checkout_Helper_Data) $this->helper('checkout')->formatPrice(...);

That calls

(Mage_Core_Model_Store) $this->getQuote()->getStore()->formatPrice($price);

Which eventually finds its way to Zend currency methods, but I don't know where the currency symbol is getting lost.

This problem only occurs when checking out with PayPal, not when paying by CC directly through the site.

Can anyone point me in the right direction? Thanks

Jamie G
  • 1,653
  • 3
  • 20
  • 43
  • 2
    Also, note that the prices that do show the € correctly also use $this->helper('checkout')->formatPrice(...); – Jamie G Sep 14 '15 at 12:13
  • 2
    I've been all over this area.. Are the totals themselves correct? Maybe provide an encoded link through here to the site in question so I can take a look? – Rob Oct 09 '15 at 21:43
  • 2
    @Rob thanks for looking. All the totals are correct, just the symbols are wrong. My text table above shows an accurate representation of what the email shows. The totals and symbols are all correct within the website, it's only the email that has the problem so I don't think access to the live site would help anyone. – Jamie G Oct 11 '15 at 11:57
  • 2
    Just in case however, the site can be found here: http://goo.gl/ntibX8 – Jamie G Oct 11 '15 at 11:57
  • 2
    Thanks. I have a couple more questions. Is this the stock email template? Second, can you log the output of your first and second calls? This way we know if it's already wrong here or if it's something else. – Rob Oct 11 '15 at 13:09
  • 2
    Hi Rob, thanks again for your help. It's the standard new order email template. The basket bit is called with {{layout handle="sales_email_order_items" order=$order}}. In trying to log the output of my calls above I actually discovered that the problem is more specific. It's only going wrong when paying via PayPal. I have now amended the question above to reflect this. I haven't however managed to log the output though because it's a nightmare to do this when it's PayPal IPN that's triggering the email! – Jamie G Oct 12 '15 at 16:52
  • 2
    Which method of the 200 Paypal payment methods are instantiating the issue? lol :P – Rob Oct 12 '15 at 21:20
  • 1
    @Rob, as you've tried the hardest, post an answer that says something - I wont accept it, but I'll give you the bounty. I *think* that's allowed! – Jamie G Oct 13 '15 at 16:40
  • 1
    I'm still interested in helping you figure this out one of those problems that's bothering me lol. Does the correct symbol show in the Magento admin panel? – Rob Oct 13 '15 at 17:18
  • 1
    Thanks Rob :) Yes, correct when looking at the order admin - it's got for example: £0.75 [€0.94], which is correct. My email for this test order showed £0.94 as the item price (incorrect) and €0.94 as the sub total (correct). It's correct on the invoice (from admin console), the credit note (from admin console), correct when I login as a customer and view previous orders. The only place I can't test is re-sending the order email, as clicking the "Send email" button at the top right of the order within admin doesn't seem to be doing anything. – Jamie G Oct 13 '15 at 17:39
  • 1
    Ah, the "send email" button, requires cron configuration to work correctly. Please install this free extension "https://github.com/AOEpeople/Aoe_Scheduler" and let me know that you have a heartbeat. I almost guarantee this is the problem with that button. – Rob Oct 13 '15 at 17:41
  • 1
    Also can you check the table "sales_flat_order" and inspect the columns "base_currency_code, global_currency_code, order_currency_code and store_currency_code" for their values? and let me know. I'm on a mission to solve this!!! – Rob Oct 13 '15 at 17:44
  • 1
    Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/92174/discussion-between-rob-and-jamie-g). – Rob Oct 13 '15 at 17:45
  • Jamie, can you let me know which PayPal method are you using ? – Sunil Verma Dec 09 '15 at 09:25
  • Hi Sunil, I'm using the built in "PayPal All-in-One Payment Solutions", with "Website Payments Standard" selected. In case it's helpful, Payment action is "sale" and Transfer cart line items is "Yes". – Jamie G Dec 09 '15 at 13:16

3 Answers3

3

In the confirmation email, there should be no call to $this->helper('checkout')->formatPrice(...) anywhere. If this is the case, the order email uses the checkout item templates instead of its own, which is probably caused by a not fully implemented custom product type or a bug in your theme.

The order totals show the right currency because the totals block uses the formatPrice() method of the order, which takes the currency of the order into account:

$this->getOrder()->formatPrice($total->getValue());

The templates for the single items also use $_order->formatPrice(...). But depending on the product type, different templates are used. This is the default template.

The blocks and templates for each product type are defined in sales.xml with the addItemRender action:

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

Modules that add product types have to register their own renderers there, as it can be seen in 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>

If this was not defined, the default renderer is the one from the checkout, where the order model itself is not used, just the single items (which have no currency information attached). There the price formatting is done by the checkout helper which has no information about the order, so it uses the currently selected store currency.

Why is this only a problem with online payments like PayPal? Because with other methods, where the order confirmation mail is created immediately with the "place order" button, the currently selected store currency is still the same as the order currency. But in the callback request from PayPal this context is lost and the default currency will be used instead.

What you need to do?

  1. Search for the <sales_email_order_items> layout handle in your layout XML files to see if the default item renderers are registered correctly
  2. Make sure that any custom product types also register their renderers
  3. Check the templates that are used by the item renderers. Maybe it's a bug in your theme and you just have to replace $this->_helper('checkout')->formatPrice() with $_order->formatPrice().
Fabian Schmengler
  • 24,155
  • 9
  • 79
  • 111
  • 1
    This answer is absolutely perfect, thank you so much @fschmenger, I can't tell you how thankful I am! I did the recommended checks and I believe my addItemRenders were all there, but your suggestion 3 did the trick (I also replaced the `Mage::helper('checkout')->formatPrice()` items). Your Magento knowledge is incredible. Thank you. – Jamie G Dec 16 '15 at 14:19
-3

This seems to be the charset currency error. You need to apply charset utf-8 by searching that particular code for email template.

jarlh
  • 42,561
  • 8
  • 45
  • 63
Gaurav
  • 23
  • 5
  • Hi Gaurav, can you elaborate on this answer please? Does it make sense to you that this only occurs when checking out with PayPal? – Jamie G Nov 30 '15 at 11:14
-4

You can change the currency symbols from System->Manage Currency->Symbols

Y.Q
  • 3