Skip to main content
added 1505 characters in body
Source Link
Yogesh Agarwal
  • 1.2k
  • 11
  • 22

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);
            }

        }
    }
}

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.

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);
            }

        }
    }
}
Source Link
Yogesh Agarwal
  • 1.2k
  • 11
  • 22

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.