You said you wanted to make your store tell the customer their unique customer code to use on graphics prepared using resources they purchase from your store.
Try the following code, which involves simply creating and uploading 2 files to your server:
1. /includes/classes/observers/class.send_extra_email_at_welcome.php
PHP Code:
<?php
/**
* @package plugins
* @copyright Copyright 2003-2012 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*
* Designed for v1.5.0, 1.5.1
*/
/**
* If you need support for multiple languages, then ...
* the following defines could be copied into a new file at /includes/languages/OTHER_LANGUAGE_FOLDERNAME/extra_definitions/send_extra_email_at_welcome.php
* and then translated there.
*/
define('EMAIL_SUBJECT_WELCOME_WITH_SPECIAL_CUSTOMER_CODE', 'Your unique customer code!');
define('TEXT_WELCOME_WITH_SPECIAL_CUSTOMER_CODE1', 'Welcome! Here is your unique customer code: ');
define('TEXT_WELCOME_WITH_SPECIAL_CUSTOMER_CODE2', 'Please be sure to use it on all graphics you produce using graphics purchased from this site.');
/**
* Observer class for sending an extra email during customer-creation/welcome process
*/
class send_extra_email_at_welcome extends base {
function __construct() {
global $zco_notifier;
$zco_notifier->attach($this, array('NOTIFY_MODULE_CREATE_ACCOUNT_ADDED_CUSTOMER_RECORD'));
}
function update(&$class, $eventID, $paramsArray = array())
{
/**
* This means "take the customer number, and add enough zeros to the left of it to make it be 3 digits long.
* str_pad($_SESSION['customer_id'],3,'0',STR_PAD_LEFT);
*
*/
$code = str_pad($_SESSION['customer_id'],3,'0',STR_PAD_LEFT);
/**
* Then the 'FXP0' prefix is added to it:
*/
$code = 'FXP0' . $code;
/**
* Now send the email to the customer
*/
$email_subject = EMAIL_SUBJECT_WELCOME_WITH_SPECIAL_CUSTOMER_CODE;
$email_text = TEXT_WELCOME_WITH_SPECIAL_CUSTOMER_CODE1 . $code . "\n\n" . TEXT_WELCOME_WITH_SPECIAL_CUSTOMER_CODE2 . "\n\n";
$html_msg['EMAIL_SUBJECT'] = $email_subject;
$html_msg['EMAIL_MESSAGE_HTML'] .= nl2br($email_text);
$customer_name = $paramsArray['customers_firstname'] . ' ' . $paramsArray['customers_lastname'];
$customer_email_address = $paramsArray['customers_email_address'];
zen_mail($customer_name, $customer_email_address, $email_subject, $email_text, STORE_NAME, EMAIL_FROM, $html_msg);
/**
* Available variables:
* $_SESSION['customer_id'] or $paramsArray['customer_id']
* $paramsArray['customers_firstname']
* $paramsArray['customers_lastname']
* $paramsArray['customers_email_address']
* $paramsArray['customers_telephone']
*/
}
}
2. /includes/auto_loaders/config.send_extra_email_at_welcome.php
Code:
<?php
/**
* @package plugins
* @copyright Copyright 2003-2012 Zen Cart Development Team
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
*/
/**
* Designed for v1.5.0, 1.5.1
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
$autoLoadConfig[190][] = array('autoType'=>'class',
'loadFile'=>'observers/class.send_extra_email_at_welcome.php');
$autoLoadConfig[190][] = array('autoType'=>'classInstantiate',
'className'=>'send_extra_email_at_welcome',
'objectName'=>'send_extra_email_at_welcome');
I ran a quick test with it, and received the expected email.
If this code is useful to you, please consider a meaningful donation to the Zen Cart project: www.zen-cart.com/donate
Bookmarks