Forums / Discounts/Coupons, Gift Certificates, Newsletters, Ads / New customers automatically join defined pricing group

New customers automatically join defined pricing group

Started by gaekwad on 1 Jul 2007, 5:32 PM · Views: 11,226

Results 21 to 24 of 24
7 Nov 2012, 5:34 AM
#21
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

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 ;)

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Nov 2012, 11:47 AM
#22
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

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.

7 Nov 2012, 4:29 PM
#23
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

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```
<?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 [B] // CUSTOMIZE HERE: The pattern is [lang_code] = group_id $this->group_rules['en'] = 3; $this->group_rules['fr'] = 4;[/B] } 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``` <?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-Creating-an-Observer-Class>

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Nov 2012, 4:43 PM
#24
abcisme avatar

abcisme

Zen Follower

Join Date:
Jun 2006
Posts:
298
Plugin Contributions:
0

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. :)