Well, I think most of my assumptions were wrong, and before_process() doesn't seem to get called at all for nochex. I really couldn't find out the reason or where the change should go. And to limit me wasting my whole life on this I did what all coders do, I created a kludge. It's not bad as kudges go.
A small observational class that clears the cart and associated data on reaching successful checkout
The autoloader, place in includes/auto_loaders
PHP Code:
<?php
// load the clearcart class
// This looks like an example I once saw
// July 2010 - Phil Chandler
$autoLoadConfig[10][] = array('autoType'=>'class',
'loadFile'=>'observers/class.ClearCart.php');
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
'className'=>'ClearCart',
'objectName'=>'ClearCart');
?>
the class
PHP Code:
<?php
/*
* Observer Class for clearing cart after successful nochex transaction
* July 2010 - Phil Chandler
*/
class ClearCart extends base {
// Attach for notifies
function ClearCart() {
$this->attach($this, array('NOTIFY_HEADER_END_CHECKOUT_SUCCESS'));
}
// Update when notified
function update(&$class, $eventID) {
if ( $_SESSION['payment'] == 'nochex_apc')
{
$_SESSION['cart']->reset(true);
unset($_SESSION['sendto']);
unset($_SESSION['billto']);
unset($_SESSION['shipping']);
unset($_SESSION['payment']);
unset($_SESSION['comments']);
unset($_SESSION['cot_gv']);
}
}
}
?>
This could be used for clearing out the cart for any reason, but here it's just for nochex. The problem seems to exist on a freshly create 1.39 system.
I hope this will save some one else some time in the future. If you do know why nochex fails to clearout the cart and/or a fix please let me know.
Phil
Bookmarks