Recently I asked a question on Stackoverflow about a weird issue when using Paypal Express in Magento. If the customer is registered during the payment process, when the order is completed, the customer is not assigned to any group and no taxes are applied to the order.

I finally found the solution myself and like to post the fix in here. It is necessary to rewrite the class app/code/core/Mage/Paypal/Model/Express/Checkout.php and modify the method _prepareNewCustomerQuote() so that it assigns the customer to the correct group.

  • Class rewrite

Create a new module in local pool. The config.xml should look like this:

<?xml version="1.0"?>
  • Method modification

Here you have the whole code of how the class should be now. Please verify there are no new lines on the original class. This might differ depending on the Magento version (this comes from Note that it’s only necessary to force the group assignation:

class YourModule_Paypal_Model_Express_Checkout extends Mage_Paypal_Model_Express_Checkout
     * REWRITE: We force the new customer assignation to the general group (1)
     * Prepare quote for customer registration and customer order submit
     * and restore magento customer data from quote
     * @return Mage_Paypal_Model_Express_Checkout
    protected function _prepareNewCustomerQuote()
        $quote      = $this->_quote;
        $billing    = $quote->getBillingAddress();
        $shipping   = $quote->isVirtual() ? null : $quote->getShippingAddress();

        $customer = $quote->getCustomer();
        /** @var $customer Mage_Customer_Model_Customer */
        $customerBilling = $billing->exportCustomerAddress();
        if ($shipping && !$shipping->getSameAsBilling()) {
            $customerShipping = $shipping->exportCustomerAddress();
        } elseif ($shipping) {
         * @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender
        if ($quote->getCustomerDob() && !$billing->getCustomerDob()) {

        if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) {

        if ($quote->getCustomerGender() && !$billing->getCustomerGender()) {

        Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer);
        $customer->setGroupId(Mage::getStoreConfig('customer/create_account/default_group')); //Force customer assignation to default group

        return $this;



Leave a Reply

Avatar placeholder

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.