Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

[TIPS] [Paypal Standard] Set language of login page for multilingual countries like Canada
 
vmaillot
Jr. Member
 
Total Posts:  19
Joined:  2009-01-05
Montreal
 

Hello

Here’s a little patch to be able to force the login page to be displayed in the current store language for countries with multilingualism like Canada :

File => app/code/code/Mage/Paypal/Model/Standard.php

public function getStandardCheckoutFormFields()
{
    [
...]

    
// insert this patch just before the last line of the function
    // canada only
    
if($a->getCountry() == 'CA')
    
{
            $rArr[
'lc']         = ((strposstrtolower(Mage::app()->getLocale()->getLocaleCode()) , 'fr') !== false) ? 'FR' 'US');
            
$rArr['locale.x']   = ((strposstrtolower(Mage::app()->getLocale()->getLocaleCode()) , 'fr') !== false) ? 'fr_XC' 'en_US');
    
}


    
// this is the last line of the function
    
return $rArr;
}

Hope it could help wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mesos Brodleto
Jr. Member
 
Total Posts:  2
Joined:  2009-10-23
 

Is this work for magento 1.4.1 too?

 
Magento Community Magento Community
Magento Community
Magento Community
 
DitesVERT
Sr. Member
 
Avatar
Total Posts:  100
Joined:  2009-03-03
 

I would like how to make this work in Magento 1.4.0.1 please!  smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
reivilo
Jr. Member
 
Total Posts:  4
Joined:  2010-09-15
 

Thanks for this tip!

Worked for me in 1.4.1.1 by creating a module as follows:

1) /app/code/local/Mycompany/Paypal/Model/Standard.php:
(with fixed local PayPal country and language; in my case BE and nl_NL)

<?php
class Mycompany_Paypal_Model_Standard extends Mage_Paypal_Model_Standard
{
    
public function getStandardCheckoutFormFields()
    
{
        $orderIncrementId 
$this->getCheckout()->getLastRealOrderId();
        
$order Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
        
$api Mage::getModel('paypal/api_standard')->setConfigObject($this->getConfig());
        
$api->setOrderId($orderIncrementId)
            ->
setCurrencyCode($order->getBaseCurrencyCode())
            
//->setPaymentAction()
            
->setNotifyUrl(Mage::getUrl('paypal/ipn/'))
            ->
setReturnUrl(Mage::getUrl('paypal/standard/success'))
            ->
setCancelUrl(Mage::getUrl('paypal/standard/cancel'));

        
// export address
        
$isOrderVirtual $order->getIsVirtual();
        
$address $isOrderVirtual $order->getBillingAddress() : $order->getShippingAddress();
        if (
$isOrderVirtual{
            $api
->setNoShipping(true);
        
}
        
elseif ($address->getEmail()) {
            $api
->setAddress($address);
        
}

        
list($items$totals$discountAmount$shippingAmount) = Mage::helper('paypal')->prepareLineItems($orderfalsetrue);
        
// prepare line items if required in config
        
if ($this->_config->lineItemsEnabled{
            $api
->setLineItems($items)->setLineItemTotals($totals)->setDiscountAmount($discountAmount);
        
}
        
// or values specific for aggregated order
        
else {
            $grandTotal 
$order->getBaseGrandTotal();
            if (!
$isOrderVirtual{
                $api
->setShippingAmount($shippingAmount);
                
$grandTotal -= $shippingAmount;
            
}
            $api
->setAmount($grandTotal)->setCartSummary($this->_getAggregatedCartSummary());
        
}

        $result 
$api->getStandardCheckoutRequest();

// Fixed local PayPal country and language
        
$result['lc']       'BE';
        
$result['locale.x''nl_NL';   

        return 
$result;
    
}
}

2) /app/code/local/Mycompany/Paypal/etc/config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <
modules>
        <
Mycompany_Paypal>
            <
version>0.0.1</version>
        </
Mycompany_Paypal>
    </
modules>
    <global>
        <
models>
            <
paypal>
                <
rewrite>
                    <
standard>Mycompany_Paypal_Model_Standard</standard>
                </
rewrite>
            </
paypal>
       </
models>
    </global>
</
config>

3) /app/etc/modules/Mycompany_All.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <
modules>
<!-- 
Module to redirect to fixed local PayPal country and language-->
        <
Mycompany_Paypal>
            <
active>true</active>
            <
codePool>local</codePool>
            <
depends>
                <
Mage_Paypal />
            </
depends>
        </
Mycompany_Paypal>
 </
modules>
</
config>

If you want to use multiple countries and/or languages you can probably use a test command as mentioned in vmaillot‘s post, but in my case this was not necessary (and for some unknown reason the mentioned test commands returned zero values in my configuration).

Hope this post can be of use for somebody. Cheers!

 
Magento Community Magento Community
Magento Community
Magento Community
 
NLMichel
Jr. Member
 
Total Posts:  5
Joined:  2009-09-24
 

Thanks reivilo!

I have a multi store setup with multiple languages and country codes. So I adjusted your code a little bit. I’m not the best programmer around, so don’t shoot me if it doesn’t work for you (it works for me!).

// Fixed local PayPal country and language
        
        $iso2 $order->getBillingAddress()->getCountry();
        
$locale_code Mage::app()->getLocale()->getLocaleCode();
            
$result['lc']       $iso2;
            
$result['locale.x'$locale_code;           

        return 
$result;
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top