0

Sometimes when I get an order from PayPal Express the customer Phone Number is always missing?

And this only happens when a customer uses the Guest Checkout Option.

I have tried changing the settings on PayPal but still no luck.

Is there a way to add a default Phone Number to an Order in Magento? See attached image.

I know I can use Event Observer to accomplish this task, but I don't know the right one to use in this case.

enter image description here

0

You should have a phone number (required) field on the checkout even its guest checkout. So the customer can submit their phone number as well.

Event/Observer method:

app/code/core/company/module/etc/config.xml

<global>
        <models>
            <company_module>
                <class>Company_Module_Model</class>
            </company_module>
            <events>
                <sales_order_place_after>
                    <observers>
                        <add_phone_paypal_orders>
                            <type>singleton</type>
                            <class>company_module/observer</class>
                            <method>addPhonePaypalOrders</method>
                        </add_phone_paypal_orders>
                    </observers>
                </sales_order_place_after>
            </events>
        </models>
    </global>

app/code/core/company/module/Model/Observer.php

<?php

class Company_Module_Model_Observer
{
public function addPhonePaypalOrders($observer)
    {
        $order = $observer->getEvent()->getOrder();
        $telephone = $order->getShippingAddress()->getTelephone();

        if(!$telephone)
        {
            $order->getShippingAddress()->setTelephone(123456789);
            try
            {
                $order->save();
            }
            catch (Exception $e)
            {
                Mage::logException($e);
            }

        }
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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