5

Afternoon all,

Run into a curious problem, I'm setting up an observer that will be triggered every time an order is made. Code is below;

Config XML:

<?xml version="1.0"?>
<config>
  <global>
    <models>
        <orderemail>
            <class>Mod_Orderemail_Model</class>
        </orderemail>
    </models>
    <events>
        <checkout_submit_all_after>
            <observers>
                <anything>
                    <type>singleton</type>
                    <class>orderemail/observer</class>
                    <method>sendEmail</method>
                </anything>
            </observers>
        </checkout_submit_all_after>
    </events> 
  </global>
</config>

Model:

<?php
class Mod_Orderemail_Model_Observer
{
    public function sendEmail($observer)
    {
        mail('me@mydomain.co.uk', "Order Submitted", "Mod Orderemail Observer Submitted");
    }
}

The issue I'm having is that the observer is only triggered when orders are submitted from one particular store view, and typically this is the store view I'm not interested in detecting orders from!

Edit: I omitted to say I also use OneStepCheckout, although (even though I need to check again) I'm sure triggers this observer. Interestingly the working Store View doesn't use OSC, just the standard One Page Checkout

Am I missing something stupid here? Mage version is (unfortunately) 1.4.1.1

Thanks,

  • Hi, have you tried disabling all store views unless one that doesn't send mail? Anyway, I normally use sales_order_place_after-Observer for this type of functionality, maybe u could try this out. – simonthesorcerer Mar 24 '13 at 12:52
  • Are you sure it doesn't get dipatched? Maybe it's just not sending the email. Replace the mail sending with some Mage::log() statement. Are you using the same payment methods for all test cases? Check your logs, maybe the problem originates somewhere else in the checkout process. – Marius Mar 27 '13 at 7:41
  • @simonthesorcerer I've not and unfortunately I can't really, due to it being a live site. I'll try that alternative hook though to see if that alters things thank you. – thebluefox Mar 28 '13 at 15:37
  • @Marius I am pretty sure, like I say I'm receiving emails from the other store view. As I've just said in my edited question I am using OSC in the troublesome Store View, which the more I think about it the more it seems obvious that that could be the issue. – thebluefox Mar 28 '13 at 15:42
  • Can't you disable OSC and place an order, that will rule it out eventually. However I don't see other option besides it changing the flow somehow. – Petar Dzhambazov Apr 2 '13 at 14:24
5

Outside of OSC - I agree with @FabianBlechschmidt - there may be something breaking the dispatch. In my case a few years back, it was:

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

I found that it was only running the last module loaded - e.g. if you use <anything> on more than one module - only the last module loaded will execute.

HTH. Cheers.

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.