Re: New customers automatically join defined pricing group
A couple comments:
$_SESSION['languages_code'] is probably more user-friendly than trying to guess which languages_id to use.
It would be more efficient to hook the NOTIFY_MODULE_CREATE_ACCOUNT_ADDED_CUSTOMER_RECORD notifier point with an observer class that takes the passed parameters and simply updates the customers table to set the desired new group number there, since that notifier point fires immediately after the customer is created.
And using an observer class means less need to touch any core files, which of course results in easier upgrades ;)
Re: New customers automatically join defined pricing group
If only I had a clue what you were talking about. LOL
I only needed the two groups, so what I have works for me, but if someone wanted to make it 100% user-friendly, that'd be great. I just have no clue how to do what you're talking about.
Re: New customers automatically join defined pricing group
Something like this should work:
Two files:
1. /includes/classes/observers/class.set_customers_group_pricing.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
* @version $Id$
*
* Designed for v1.3.9-thru-v1.6.0
*
* includes support for COWOA "no-account"
*/
class set_customers_group_pricing extends base {
private $group_rules = array();
function __construct() {
global $zco_notifier;
$zco_notifier->attach($this, array('NOTIFY_MODULE_CREATE_ACCOUNT_ADDED_CUSTOMER_RECORD', 'NOTIFY_MODULE_NO_ACCOUNT_ADDED_CUSTOMER_RECORD'));
$this->attach($this, array('NOTIFY_PAYPALEXPRESS_CREATE_ACCOUNT_ADDED_CUSTOMER_RECORD')); // this line only works since v1.6.0
// The group_id number here is from the "ID" column in your Admin->Customers->GroupPricing screen
// CUSTOMIZE HERE: The pattern is [lang_code] = group_id
$this->group_rules['en'] = 3;
$this->group_rules['fr'] = 4;
}
function update(&$class, $eventID, $paramsArray = array())
{
global $db;
$customer_id = $paramsArray['customer_id'];
$sql = "update " . TABLE_CUSTOMERS . "
set customers_group_pricing = " . $this->group_rules[$_SESSION['languages_code']] . "
where customers_id = " . (int)$customer_id;
$db->Execute($sql);
}
}
2. /includes/auto_loaders/config.set_customers_group_pricing.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.3.9 thru v1.6.0
*/
if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}
$autoLoadConfig[190][] = array('autoType'=>'class',
'loadFile'=>'observers/class.set_customers_group_pricing.php');
$autoLoadConfig[190][] = array('autoType'=>'classInstantiate',
'className'=>'set_customers_group_pricing',
'objectName'=>'set_customers_group_pricing');
Reference for additional reading on the concepts: http://www.zen-cart.com/entry.php?4-...Observer-Class
Re: New customers automatically join defined pricing group
Beautiful! Thank you! I am sure this will be very helpful for someone trying to accomplish this task. :)