Stumped on notifiers, help?
I read through the WIKI and I thought I got the general idea... but all I get is a blank page! I'm trying to get a message header when someone adds an item(s) to their cart.
this is what I have in /includes/classes/observers/class.addProductMessage.php
Code:
<?php
/**
* Observer class used to add a free product to the cart if the user spends more than $x
*
*/
class addProductMessage extends base {
function addProductMessage() {
$_SESSION['cart']->attach($this, array('NOTIFIER_CART_ADD_CART_END');
}
function update(&$class, $eventID) {
$messageStack->add_session('header', 'test!', 'success');
}
}
?>
And this is what I have in /includes/auto_loaders/config.addProductMessage.php
Code:
<?php
$autoLoadConfig[85][] = array('autoType'=>'class',
'loadFile'=>'observers/class.addProductMessage.php');
$autoLoadConfig[85][] = array('autoType'=>'classInstantiate',
'className'=>'addProductMessage',
'objectName'=>'addProductMessage');
?>
From the examples given, I presumed this would work on the first shot because its so simple! What am I doing wrong???
- Steven
Re: Stumped on notifiers, help?
might try adding this to your update element:
global $messageStack;
Re: Stumped on notifiers, help?
Well, that could explain why I might not get a proper output, but I'm getting no output. Ok, I found I was missing a ) in the function addProductMessage and thought that was the problem... and it was a problem. But still, not the only problem. But if I change the update function to simply
Code:
function update(&$class, $eventID) {
print "hello";
}
I still just get a blank screen.
- Steven
Re: Stumped on notifiers, help?
Well, now I'm even more confused. I got it to work but I'm not sure what I did. I tried your globals thing and that didn't do it. I found the rogue bracket, and that didn't do it. Then I changed some more stuff to no avail, but when I changed it back it works. So I'm not sure what I did. The above code with the missing ) put in works as expected now...
weird.
- Steven
Re: Stumped on notifiers, help?
You probably know this, but just in case:
If you get a blank screen, then often (but not always!) your server log is a good place to look. You might see a message like this:
[client 127.0.0.1] PHP Parse error: parse error, unexpected ':', expecting ',' or ';' in /var/www/html/higher_1.3/includes/templates/custom/templates/tpl_product_info_display.php on line 291, referer: http://localhost/higher_1.3/index.php
This one shows us that l. 291 in tpl_product_info_display.php is broken.
/var/log/httpd/error_log on my FC4 box running Apache.
Good luck,
Scott
Re: Stumped on notifiers, help?
Actually, I didn't know that :) Thanks.
But I don't know where to find the log. I'm running on a local windows server using apache2triad. I found a logs folder, and even an error file within that... but there are absolutely no parse errors in it, just file not found errors (and I know what was generating those).
I'd like to find the log you speak of.
- Steven
Re: Stumped on notifiers, help?
Found it! In a seperate php folder - how handy!
So for anyone in a similar setting... look here: C:\apache2triad\php\logs
Thanks for the tip.
- Steven