I am trying to get this working and I am going wrong somewhere LOL I wonder if someone with more knowledge than me can tell me where I am going wrong?
http://www.zen-cart.com/wiki/index.p..._World_Example
I have copied the following code into includes/auto_loaders in a file called config.freeProduct.php
PHP Code:
<?php
$autoLoadConfig[90][] = array('autoType'=>'class',
'loadFile'=>'observers/class.freeProduct.php');
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
'className'=>'freeProduct',
'objectName'=>'freeProduct');
?>
And then the code underneath in the tutorial (changing the product id to my free product id) into includes/classes/observers/class.freeProduct.php
PHP Code:
<?php
/**
* Observer class used to add a free product to the cart if the user spends more than $x
*
*/
class freeProduct extends base {
/**
* The threshold amount the customer needs to spend.
*
* Note this is defined in the shops base currency, and so works with multi currency shops
*
* @var decimal
*/
var $freeAmount = 10;
/**
* The id of the free product.
*
* Note. This must be a true free product. e.g. price = 0 Also make sure that if you don't want the customer
* to be charged shipping on this, that you have it set correctly.
*
* @var integer
*/
var $freeProductID = 422;
/**
* constructor method
*
* Attaches our class to the $_SESSION['cart'] class and watches for 2 notifier events.
*/
function freeProduct() {
$_SESSION['cart']->attach($this, array('NOTIFIER_CART_ADD_CART_END', 'NOTIFIER_CART_REMOVE_END'));
}
/**
* Update Method
*
* Called by observed class when any of our notifiable events occur
*
* @param object $class
* @param string $eventID
*/
function update(&$class, $eventID) {
if ($_SESSION['cart']->show_total() >= $this->freeAmount && !$_SESSION['cart']->in_cart($this->freeProductID) ) {
$_SESSION['cart']->add_cart($this->freeProductID);
}
if ($_SESSION['cart']->show_total() < $this->freeAmount && $_SESSION['cart']->in_cart($this->freeProductID) ) {
$_SESSION['cart']->remove($this->freeProductID);
}
if ($_SESSION['cart']->in_cart($this->freeProductID)) {
$_SESSION['cart']->contents[$this->freeProductID]['qty'] = 1;
}
}
}
?>
Uploaded them to the relevant directories...but when I added a product to cart I got a blank page, so I know I am missing something OR there is a mistake somewhere and any help would be appreciated to get this working because I really wanna LOL
**edit...I took the files out and I am still getting blank page, so maybe it's not this at fault....more digging for me it seems LOL