Magento 1.9 Paypal Guest Customer Name

A lot of people seem to have issues with this, when a guest checkout checks out via Paypal the customer name field in Magento just defaults to guest, this means whenever a guest gets an email with their order confirmation it says ‘hello guest’.

To get around this start by copying:

app/code/core/Mage/Paypal/Model/Express/Checkout.php

To:

app/code/local/Mage/Paypal/Model/Express/Checkout.php

Then find this:

protected function _prepareGuestQuote()
{
    $quote = $this->_quote;
    $quote->setCustomerId(null)
        ->setCustomerEmail($quote->getBillingAddress()->getEmail())
        ->setCustomerIsGuest(true)
        ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
    return $this;
}

Replace the above code with this:

protected function _prepareGuestQuote()
{
    $quote = $this->_quote;
    $quote->setCustomerId(null)
        ->setCustomerFirstname($quote->getBillingAddress()->getFirstname()) 
        ->setCustomerLastname($quote->getBillingAddress()->getLastname())
        ->setCustomerEmail($quote->getBillingAddress()->getEmail())
        ->setCustomerIsGuest(true)
        ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
    return $this;
}

This then gets the billing address details and adds them to the Magento quote

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.