Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15
  1. #11
    Join Date
    Aug 2012
    Posts
    21
    Plugin Contributions
    0

    Default Re: How to assign unique account numbers OR usernames?

    Quote Originally Posted by gjh42 View Post
    No matter how many digits the customer id has, it will always be unique and useable as a license identifier. If you don't want any one-digit licenses, create nine test customers and all of the real ones will have at least a two-digit id. If you want more digits to start, there will be a way to update the database with a specific number as a takeoff point.

    This is not a "random 5-digit number", but it is useable for your customers and immediately available without a lot of custom coding.
    If that's the easiest way, to have the IDs start with say 10000, then that's fine. Could you guide me to how to set the code to do that? Also will/can Zen Cart email the customers that number in the Welcome Message as they register?

    Thanks so much for you all help! I'm sorry if I am being a pain

  2. #12
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: How to assign unique account numbers OR usernames?

    You would need a SQL statement (or group of statements) to run once in adin > Tools > Install SQL Patches. I would have to do some research for the correct formulation; DrByte would be able to tell you quickly, and I would want his assurance that it only needs to be updated in one place.

    I'm not sure if the welcome e-mail includes the customer id, but you could create a test customer (using an e-mail you have access to) and see what it says.

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

    Default Re: How to assign unique account numbers OR usernames?

    Well, don't go changing customer numbers to start at 10,000.
    That will waste space in the number of customers your store can handle, since the current architecture is based off an auto-increment field of an INT data type. It's the same reason one should never force their order numbers to mysteriously start at a higher number.

    If it's just a 5-digit code you're after, you can start out by pre-pending a leading zero, or maybe two, until your customer numbers are organically high enough.
    You will need to write custom code to generate any additional prefixes, and also to include any of that information in a welcome email, and/or add it to their My Account screens, etc.
    .

    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. #14
    Join Date
    Aug 2012
    Posts
    21
    Plugin Contributions
    0

    Default Re: How to assign unique account numbers OR usernames?

    Quote Originally Posted by DrByte View Post
    Well, don't go changing customer numbers to start at 10,000.
    That will waste space in the number of customers your store can handle, since the current architecture is based off an auto-increment field of an INT data type. It's the same reason one should never force their order numbers to mysteriously start at a higher number.

    If it's just a 5-digit code you're after, you can start out by pre-pending a leading zero, or maybe two, until your customer numbers are organically high enough.
    You will need to write custom code to generate any additional prefixes, and also to include any of that information in a welcome email, and/or add it to their My Account screens, etc.
    I do not posess nearly enough programming knowledge to be able to customize my code in that way. I was hoping that there was an addon out there somewhere that I just hadn't found that a techy guru had alreay created! Perhaps I should scour the internet for a spreadsheet formula that could preformat my columns to create ID numbers. Then I shall have to bite the bullet with manually emailing each customer their license numbers.

    Thanks you all for giving it a good try!

  5. #15
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: How to assign unique account numbers OR usernames?

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

    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.

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v153 How do you make the model numbers unique?
    By jokkah in forum Setting Up Categories, Products, Attributes
    Replies: 13
    Last Post: 1 Oct 2014, 10:54 PM
  2. v151 How do I assign unique SKUs to product variants/attributes?
    By wzeller in forum General Questions
    Replies: 3
    Last Post: 6 Sep 2013, 01:59 AM
  3. unique article numbers for attributes
    By sieg01 in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 15 Dec 2011, 10:15 PM
  4. Maintaining Unique Model Numbers
    By ted in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 19 Jun 2006, 12:11 AM

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