Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2013
    Location
    Portishead, North Somerset, United Kingdom
    Posts
    34
    Plugin Contributions
    0

    Default Add a unique database field to Zen_Customers table.

    Hi Everyone,

    I need to add another database field to the [zen_customers] table in the database when they sign up to the store. It needs to be a 8-12 character string that is unique and made from only lower case letters and numbers. Lets call it [customers_designid].

    Does anyone have any idea how this can be achieved or where to start?

    Reason for extra database field:
    I'm sending users to another website via a URL with the [customers_designid] (extra field) tagged to the end. This [customers_designid] will become the users ID for that website. They will then be linked back and forth via the ID without any sensitive data being transferred. This avoids all the session expiry and security risks associated. I know I could use the [customers_id] but I want it more secure than an incremented number.

    As usual, any pointers would be much appreciated.

    Thanks

    Matt

  2. #2
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: Add a unique database field to Zen_Customers table.

    Hi Matt,

    This is a good place to start with ZenCart v1.51...
    SQL Update - Add the customers_designid field to the customers table:

    ALTER TABLE `customers` ADD `customers_designid` VARCHAR(12) NOT NULL ;

    {for uninstall only}

    To Remove the customer_designid field:
    ALTER TABLE `customers` DROP `customers_designid`;

    {for uninstall only}

    And this code will allow you to input your own [customers_designid] strings in admin for testing...

    Add the customers_designid input to the customer data:
    admin/customers.php
    line 101
    $customers_designid = zen_db_prepare_input($_POST['customers_designid']);
    line 258
    'customers_designid' => $customers_designid,
    line 361
    c.customers_email_format, c.customers_group_pricing, c.customers_designid,
    line 634 - below the email - within the </table>
    <tr>
    <td class="main"><?php echo CUSTOMERS_DESIGNID_TITLE; ?></td>
    <td class="main">
    <?php
    echo zen_draw_input_field('customers_designid', $cInfo->customers_designid, zen_set_field_length(TABLE_CUSTOMERS, 'customers_designid', 50), false);
    ?>
    <?php
    echo CUSTOMERS_DESIGNID_NOTES; ?>
    </td>
    </tr>

    You'll need to define CUSTOMERS_DESIGNID_TITLE and CUSTOMERS_DESIGNID_NOTES here:
    admin/includes/languages/english/customers.php
    define('CUSTOMERS_DESIGNID_TITLE','Customer Design ID:');
    define('CUSTOMERS_DESIGNID_NOTES', 'Customer Design ID Notes');

    Once you get it working between the two sites you'll have to decide just how closely you'd like the new [customers_designid] to mimic ZenCart's [customers_id] and where you'd like to display this data in admin. Then it's a matter of adding [customers_designid] to the create_account fileset and passing the new data to the end of the shopping cart if needed.

    If you plan to use auto increment to create the [customers_designid] value be sure to remove the admin input textbox above when you're done testing to prevent duplicate id's.
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    Twitch Base8 - Obsidian - This, is what's new.

  3. #3
    Join Date
    Oct 2013
    Location
    Portishead, North Somerset, United Kingdom
    Posts
    34
    Plugin Contributions
    0

    Default Re: Add a unique database field to Zen_Customers table.

    Sorry for the delay, many thanks for the reply. I'll give this a go when I get a spare 30 mins!! :-)

 

 

Similar Threads

  1. "1034 Incorrect key file for table 'zen_customers'; try to repair it
    By albert7 in forum Upgrading from 1.3.x to 1.3.9
    Replies: 3
    Last Post: 31 Aug 2011, 07:26 PM
  2. Replies: 2
    Last Post: 25 Jul 2011, 06:42 AM
  3. for the products_prid in zencart database, table: orders field
    By vivifashion in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 6 Nov 2009, 04:45 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