2

our magento has installed :

0 Step Checkout

http://www.magentocommerce.com/magento-connect/0-step-checkout.html

MSP Multi-Flat Shipping

http://www.magentocommerce.com/magento-connect/multi-flat-shipping.html

And we are using Paypal Express Checkout without Order Review Page, and Paypal would return us the shipping address after paying process is finished. And we only use the shipping address from paypal, so the Checkout page has no address textbox allows customer to type address.

Here is the setting of Multi-Flat Shipping : Created 4 x Flat Rate shipping method with "All Countries Allow" . 0 Step Checkout : Didn't set default country as UK (let say)

And the problem is happened at Checkout. For example If the customer finished paying at Paypal, and deliver to "USA". but the parameter at paypal log that says shipping address become "UK" (the default country at 0 Step Checkout).

I have checked the Paypal log, the Country code has been changed when Magento calling DoEC API, but the country still "USA" at SetEC and GetEC.

I have no idea where (the code) has changed the Country to "UK" from "USA".

Is there anyone can help me and tell the reason of causing this problem(i know it is about the request data, but i have no idea where can fix it.). and please kindly give me a suggestion that I should pursue or it is the nature of Paypal Express doing.

1 Answer 1

0

The Problem is caused by the Method: Mage_Paypal_Model_Express_Checkout::_involveNewCustomer() in line 1045 and 1051. It do not pass any store parameter:

protected function _involveNewCustomer()
{
    $customer = $this->_quote->getCustomer();
    if ($customer->isConfirmationRequired()) {
        $customer->sendNewAccountEmail('confirmation');
        $url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
        $this->getCustomerSession()->addSuccess(
            Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url)
        );
    } else {
        $customer->sendNewAccountEmail();
        $this->getCustomerSession()->loginById($customer->getId());
    }
    return $this;
}

That causes the call $this->_getWebsiteStoreId(null) in Mage_Customer_Model_Customer::sendNewAccountEmail() in line 603:

public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
{
    $types = array(
        'registered'   => self::XML_PATH_REGISTER_EMAIL_TEMPLATE, // welcome email, when confirmation is disabled
        'confirmed'    => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE, // welcome email, when confirmation is enabled
        'confirmation' => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE, // email with confirmation link
    );
    if (!isset($types[$type])) {
        Mage::throwException(Mage::helper('customer')->__('Wrong transactional account email type'));
    }

    if (!$storeId) {
        $storeId = $this->_getWebsiteStoreId($this->getSendemailStoreId());
    }

    $this->_sendEmailTemplate($types[$type], self::XML_PATH_REGISTER_EMAIL_IDENTITY,
        array('customer' => $this, 'back_url' => $backUrl), $storeId);

    return $this;
}

Which leads to choosing the first store of the current website in:

protected function _getWebsiteStoreId($defaultStoreId = null)
{
    if ($this->getWebsiteId() != 0 && empty($defaultStoreId)) {
        $storeIds = Mage::app()->getWebsite($this->getWebsiteId())->getStoreIds();
        reset($storeIds);
        $defaultStoreId = current($storeIds);
    }
    return $defaultStoreId;
}

You need to rewrite the method Mage_Paypal_Model_Express_Checkout::_involveNewCustomer() and pass the current store ID:

protected function _involveNewCustomer()
{
    $customer = $this->_quote->getCustomer();
    if ($customer->isConfirmationRequired()) {
        $customer->sendNewAccountEmail('confirmation', '', Mage::app()->getStore()->getId());
        $url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
        $this->getCustomerSession()->addSuccess(
            Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url)
        );
    } else {
        $customer->sendNewAccountEmail('registered', '', Mage::app()->getStore()->getId());
        $this->getCustomerSession()->loginById($customer->getId());
    }
    return $this;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.