Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24
  1. #21
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

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

    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.

  2. #22
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

    Default 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.

  3. #23
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default 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
    .

    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.

  4. #24
    Join Date
    Jun 2006
    Posts
    298
    Plugin Contributions
    0

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

 

 
Page 3 of 3 FirstFirst 123

Similar Threads

  1. Move customers automatically to defined pricing group after first purchase
    By mybaby in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 5
    Last Post: 24 Oct 2014, 03:07 PM
  2. v151 Group Pricing automatically assigned from email link
    By denliv in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 0
    Last Post: 24 Mar 2014, 11:17 PM
  3. New customer group - auto-join a group?
    By solid in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 7
    Last Post: 8 Feb 2011, 08:44 PM
  4. automatically add customers to group pricing
    By trickobrien in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 4
    Last Post: 23 Aug 2010, 11:10 AM
  5. Add certain customers to Group automatically...
    By rebekah in forum Managing Customers and Orders
    Replies: 5
    Last Post: 20 Apr 2009, 10:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR