Zen Cart Logo
Forums / General Questions / why does not $zco_notifier->notify(...) work for ipn_main_handler.php?

why does not $zco_notifier->notify(...) work for ipn_main_handler.php?

Views: 997

Results 1 to 3 of 3
8 Oct 2012, 8:46 AM
#1
linjuming avatar

linjuming

Zen Follower

Join Date:
Apr 2012
Posts:
151
Plugin Contributions:
0

why does not $zco_notifier->notify(...) work for ipn_main_handler.php?

why does not $zco_notifier->notify(...) work for ipn_main_handler.php?
I am sure that my code works in usual pages , such as when I pay with moneyOrder, it will create a xxxxx.txt at basehost.

\includes\classes\observers\class.observers_linjuming.php codes:

<?php 
	class observers_linjuming extends base{
		function __construct(){
			global $zco_notifier;
			// $zco_notifier->attach($this,array('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE'));
			$zco_notifier->attach($this,array('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE'));
		}
		function update(&$class,$eventID){
			// 添加或插入用户积分
			if($eventID == 'NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE'){
				file_put_contents('xxxxx.txt','dddf');
			}
		}
	}

\includes\auto_loaders\config.linjuming.php codes:

<?php 

$autoLoadConfig[1000][] = array(	'autoType'=>'class',
													'loadFile'=>'observers/class.observers_linjuming.php');
$autoLoadConfig[1000][] = array(	'autoType'=>'classInstantiate',
													'className'=>'observers_linjuming',
													'objectName'=>'observers_linjuming');

8 Oct 2012, 10:43 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,701
Plugin Contributions:
56

Re: why does not $zco_notifier->notify(...) work for ipn_main_handler.php?

This bug has been fixed in 1.5.0. For 1.3.9h you need to modify the code yourself.

Edit the file ipn_main_handler.php at the top level of your store, find the line

$order->send_order_email($insert_id, 2);

it's line 354 in 1.3.9h (line 253 in 1.3.8, line 219 in 1.3.7). Change this to:

$order->send_order_email($insert_id, 2);
require(DIR_WS_CLASSES . 'observers/class.msg_owner.php');
$mo = new msg_owner();
$mo->update($this, 'NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL');

(These notes are from the SMS on Sale plugin, which faced the same issue you are dealing with.)

Note further that the current recommendation is to use Express Checkout and not IPN. IPN is failure prone.

9 Oct 2012, 1:00 AM
#3
linjuming avatar

linjuming

Zen Follower

Join Date:
Apr 2012
Posts:
151
Plugin Contributions:
0

Re: why does not $zco_notifier->notify(...) work for ipn_main_handler.php?

thank you very much ,your reply is very great help for me.