Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24
  1. #21
    Join Date
    Jan 2004
    Posts
    60,425
    Blog Entries
    4
    Plugin Contributions
    144

    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!
    Donations always welcome: www.zen-cart.com/donate

    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
    217
    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
    60,425
    Blog Entries
    4
    Plugin Contributions
    144

    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!
    Donations always welcome: www.zen-cart.com/donate

    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
    217
    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. Group Pricing for One Product Category?
    By PattyGale in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 15
    Last Post: 22 Sep 2009, 10:21 PM
  2. group pricing
    By kmickus in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 3
    Last Post: 2 May 2007, 09:46 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
  •