Using v1.3.9h
I am trying to learn how to use Observers, I've followed examples and searched forum but I cannot find what I'm doing wrong.
I have class.mycheckoutobs.php located at /includes/classes/observers
I have config.mycheckoutobs.php at /includes/auto_loadersPHP Code:<?php
class mycheckoutobs extends base {
function mycheckoutobs() {
$this->attach($this, array('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL'));
}
function update(&$callingClass, $notifier, $paramsArray) {
$filename = 'test.txt';
$somecontent = "Add this to the file\n";
echo "Current directory is " . getcwd();
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
print "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (!fwrite($handle, $somecontent)) {
print "Cannot write to file ($filename)";
exit;
}
print "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
} else {
print "The file $filename is not writable";
}
}
}
?>
This is just a test to learn. Anyone see what is wrong?PHP Code:<?php
$autoLoadConfig[10][] = array('autoType'=>'class',
'loadFile'=>'observers/class.mycheckoutobs.php');
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
'className'=>'mycheckoutobs',
'objectName'=>'mycheckoutobs');
?>


Reply With Quote

