1

i want to create email method. if customer select free shipping method then admin and user both will get an custom email.

how to do that? need help.

there are two shipping . one is paid and second is free. if customer select free shipping method and place the order then admin and customer both will get email notification.

need help how to do that?

in module folder Custom_shipping.xml

   <?xml version="1.0"?>
 <config>
     <modules>
       <Custom_Shipping>
         <active>true</active>
          <codePool>local</codePool>

        </Custom_Shipping>
      </modules>
  </config>

in Model Folder Observer.php

   <?php

   class Custom_Shipping_Model_Observer(){

    public function salesOrderShipmentSaveBefore($observer)
    {

    $shipment = $observer->getShipment();
    $order = $shipment->getOrder();
    $storeId = $order->getStore()->getStoreId();

     die('test');


     }


}

ann etc/config.xml

      <?xml version="1.0"?>
  <config>
   <modules>
    <Custom_Shipping>
        <version>1.0</version>
    </Custom_Shipping>
  </modules>
<global>
   <events>             
      <sales_order_shipment_save_before>
        <observers>
            <shipping>
                <type>singleton</type>
                <class>shipping/observer</class>
                <method>salesOrderShipmentSaveBefore</method>
            </shipping>
        </observers>
     </sales_order_shipment_save_before>
     </events>
     </global>
     </config>
Jack Torris
  • 407
  • 1
  • 6
  • 12
  • What is the exact problem? – Fabian Blechschmidt Feb 18 '14 at 13:53
  • i don't know what is the issue. i created this module and unfortunately it is not working. i want to send email to user if user place place the order using freeshipping. as you suggested to use observer and sales_order_shipment_save_before i just tried to create the observer but it isn't working. can you help me? – Jack Torris Feb 19 '14 at 04:27
  • Is the code called? Is the file included? Does the module show up in the backend? http://magento.stackexchange.com/questions/428/fundamentals-for-debugging-a-magento-store – Fabian Blechschmidt Feb 19 '14 at 13:34
  • yes . module show up in system >> configuration >> advanced. it is is enable. i don't know why it is not firing the action – Jack Torris Feb 20 '14 at 11:19

2 Answers2

2

The problem appears to be you are missing the model definition in your config.xml so the observer does not get called.

You have two options.

Either update <class>custom_shipping/observer</class> to use <class>Custom_Shipping_Model_Observer</class>

Or create the following section in your config.xml:

<global>
    <models>
        <custom_shipping>
            <class>Custom_Shipping_Model</class>
        </custom_shipping>
    </models>
</global>

Thanks to Fabian for pointing out <shipping> is already in use :)

David Manners
  • 27,241
  • 9
  • 76
  • 220
0

Hook into the event sales_order_shipment_save_before check wether the order has an ID, if no, check the method and if the method is free, then send an email.

Further informations:

Fabian Blechschmidt
  • 35,388
  • 8
  • 75
  • 182