0

i was already done sms integration if the order placed by customer using my website. But i want to send sms to customer mobile number if order placed by admin (site owner) using magento admin panel. In magento admin panel has option to place order for the customer.

1

1 Answer 1

1

create an event/ observer on when order place from admin

<adminhtml>
<events>
    <checkout_submit_all_after>
        <observers>
            <anything> <!-- <<< THIS NEEDS TO BE UNIQUE -->
                <type>singleton</type>
                <class>orderemail/observer</class>
                <method>sendsms</method>
            </anything><!-- <<< THIS NEEDS TO BE UNIQUE -->
        </observers>
    </checkout_submit_all_after>
</events> 
</adminhtml>

on Observer.php and in function sendsms()

public function sendsms(Varien_Event_Observer $observer)
    {
        $order = $observer->getEvent()->getOrder();

    // send sm herr
        Mage::log(
            "{$order}",
            null, 
            'product-updates.log'
        );
    }

you can get order data by $observer

**Edit:**You can Telephone no from

$order->getBillingAddress()->getTelephone();

or $order->getShippingAddress()->getTelephone(); and for get Order grandtotal

$order->getGrandTotal();

Edit: for your request: Step1:First of all create module control file Module name as Amit_Custommodule.xml at app/etc/modules/. - See more at: http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/#sthash.nuncYnVE.dpuf

<?xml version="1.0"?>
<config>
    <modules>
        <Amit_Custommodule>
            <codePool>community</codePool>
            <active>true</active>
        </Amit_Custommodule>
    </modules>
</config>

Step2: config.xml is app/code/community/Amit/Custommodule/etc/ and code is

<?xml version="1.0" ?>
<config>
    <modules>
        <Amit_Custommodule>
            <version>1.0.0</version>
        </Amit_Custommodule>
    </modules>
    <global>
        <models>
            <custommodule>
                <class>Amit_Custommodule_Model</class>
            </custommodule>
        </models>
    </global>
<adminhtml>
<events>
    <checkout_submit_all_after>
        <observers>
            <anything> 
                <type>singleton</type>
                <class>custommodule/observer</class>
                <method>sendsms</method>
            </anything>
        </observers>
    </checkout_submit_all_after>
</events> 
</adminhtml>
</config>

Step3:Observer.php at app/code/community/Amit/Custommodule/Model/ code is

<?php
class Amit_Custommodule_Model_Observer
{
public function sendsms(Varien_Event_Observer $observer)
    {
        $order = $observer->getEvent()->getOrder();

    $telephone =$order->getBillingAddress()->getTelephone();
    //or 
    $telephone =$order->getShippingAddress()->getTelephone();
    $order->getGrandTotal()
    // write here your sms code:
    }}
3
  • Thank for your reply, if you don't mind can you explain where i need to add the above code and i want to get order id, customer mobile number, ordered total amount, i already had customer sms code and done if customer place the order using website. now i want send sms to customer mobile if the order placed by admin for any customer via magento admin panel.
    – Vetrivel
    Commented Aug 18, 2014 at 6:38
  • thanks, please can you tell me where exactly i need to add the above code, tell me the path, i m new for magento. thanks in advance.
    – Vetrivel
    Commented Aug 18, 2014 at 9:12
  • @Amit. I created module and observer.php, config.xml, Amit_Custommodule.xml as you explained above. But still i didnt get messages automatically please Amit Help me. Commented Dec 25, 2015 at 7:02

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.