Two, maybe three steps:
1. Upload the following as a new file to your site, as: /includes/classes/observers/class.observerProductsInCartMessage.php
Code:
<?php
/**
* if the site is multilingual, copy the following define() statement to a new extra custom language file at /includes/languages/your_language_folder/extra_definitions/extra_products_message.php
*/
if (!defined('DEFINED_LANGUAGE_STRING_FOR_SPECIAL_PRODUCT_MESSAGE')) {
define('DEFINED_LANGUAGE_STRING_FOR_SPECIAL_PRODUCT_MESSAGE', "As there are some special order items in your basket, please note that the complete order shall be delivered within seven working days whilst we source your SO items - we endeavour to contact you within 24 hours of your order for a more precise update.");
}
/**
* If a customer adds certain products to their cart, display a special message on the shopping-cart page
*/
class observerProductsInCartMessage extends base
{
/**
* list the affected product IDs in this array, separating each with a comma:
*/
var $products_array = array(10, 11, 12, 13);
function __construct ()
{
$_SESSION['cart']->attach($this, array(
'NOTIFIER_CART_ADD_CART_END' ,
'NOTIFIER_CART_REMOVE_END',
'NOTIFIER_CART_GET_PRODUCTS_END'));
}
function update (&$class, $eventID, $paramsArray = array())
{
global $messageStack;
static $alertSent = FALSE;
/**
* NOTE: The $alertSent variable is used to prevent displaying the message multiple times when multiple items are in the cart
*/
$msgLocation = 'shopping_cart';
foreach($this->products_array as $key) {
if ($_SESSION['cart']->in_cart_check('products_id', $key) > 0) {
if ($alertSent == FALSE) $messageStack->add_session($msgLocation, DEFINED_LANGUAGE_STRING_FOR_SPECIAL_PRODUCT_MESSAGE, 'caution');
$alertSent = TRUE;
}
}
}
}
2. Upload the following as a new file to your site, as: /includes/auto_loaders/config.observerProductsInCartMessage.php
Code:
<?php
/**
* @package observerscripts
* @copyright Copyright 2003-2013 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*/
$autoLoadConfig[200][] = array('autoType'=>'class',
'loadFile'=>'observers/class.observerProductsInCartMessage.php');
$autoLoadConfig[200][] = array('autoType'=>'classInstantiate',
'className'=>'observerProductsInCartMessage',
'objectName'=>'observerProductsInCartMessage');
3. Optionally set up multilingual support by creating the extra_definitions language file as described in the beginning of the code in #1 above.
If it suits your needs, donations always welcome at www.zen-cart.com/donate
Bookmarks