Results 1 to 6 of 6
  1. #1
    Join Date
    May 2006
    Posts
    59
    Plugin Contributions
    0

    Adding fields to customer details-- 2 questions

    I need to add a customer's mobile phone provider to his account information. Before I start modifying the code (using templates as much as possible), I wanted to see if there is a way to add a field to the list of customer details?

    Through admin->configuration->customer details I see the Create Account Default Country ID. I would like to add a 'Create Account Default Carrier ID' but I don't see a way to add customer details.

    Question 1: Have I missed it? If so, how do I add this field?

    Using Tools->Developers Toolkit and searching for the constant, SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY, I get the following listing.

    Developers Tool Kit
    Lookup CONSTANT Definitions
    Key: SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY
    Title: Create Account Default Country ID
    Description: Set Create Account Default Country ID to:
    Default is 223
    Value: 223
    Group: ID#5 Customer Details
    Edit Reset

    I want to add a similar constant, SHOW_CREATE_ACCOUNT_DEFAULT_CARRIER but I'm not sure which file to add it to?

    Question 2: Even using the developer's tools, I can't find the name of the file where it's defined, just where it's used. It's got to be there somewhere--I'm just missing it.

    Here's my search and the listing:
    Searching 1113 files ... for: SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY

    /home/content/b/e/a/bearBud2206/html/store/includes/templates/template_default/templates/tpl_modules_checkout_new_address.php

    Line #90 : $selected_country = ($_POST['country']) ? $country : SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY;

    /home/content/b/e/a/bearBud2206/html/store/includes/templates/template_default/templates/tpl_modules_create_account.php

    Line #108 : $selected_country = ($_POST['country']) ? $country : SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY;

    Match Lines found: 2


    Thanks,
    jdl

  2. #2
    Join Date
    May 2006
    Posts
    59
    Plugin Contributions
    0

    Default Re: Adding fields to customer details-- 2 questions

    I had to get this done, so I just modified the code where necessary and took notes. If there was a better way, please let me know.

    If not, I would be happy to share my notes with others who want to make similar modifications.

    You can see the carrier changes at:
    https://www.edufone.com/store/index.php?main_page=login

    jdl

  3. #3
    Join Date
    Feb 2006
    Posts
    3
    Plugin Contributions
    0

    Default Re: Adding fields to customer details-- 2 questions

    JDL
    Could you post your notes
    Thanks
    Rob

  4. #4
    Join Date
    May 2006
    Posts
    59
    Plugin Contributions
    0

    Default Re: Adding fields to customer details-- 2 questions

    Here are my notes. I wanted to attach them as a Word file since the formatting will probably get messed up with cut and paste but the file's 171kb. You can email me at jade "at" edufone.com and I'll email you the attachment.

    There may have been other things I could have done to make it simpler so if anyone has other ideas, please let me know.

    The table at the top shows all of the files that I changed. The messy notes follow and they show what I changed. Most of those notes haven't yet made it into the table so you'll want to consult both the table and the notes.

    jdl




    File modified Change
    store/includes/modules/create_account.php telephone number must be exactly 10 digits
    store/includes/modules/pages/checkout_success/header.php
    store/includes/functions/html_output.php Added function, zen_get_carrier_list
    store/includes/functions/functions_lookups.php copied function get_countries() to get_carriers()

    store/includes/templates/myTemplates/templates/tpl_modules_create_account.php
    Added code to display list of carriers
    store/admin/includes/functions/general.php zen_cfg_pull_down_carrier_list_none
    store/includes/modules/pages/create_account/jscript_form_check.php
    check_select("carrier", "", "<?php echo ENTRY_CARRIER_ERROR; ?>");
    store/includes/form_check.js.php check_select("carrier", "", "<?php echo ENTRY_CARRIER_ERROR; ?>");

    store/includes/templates/myTemplate/tpl_modules_checkout_new_address.php added phone number and carrier
    store\includes\templates\myTemplate\templates\tpl_account_edit_default.php When user edits his account info, add carrier
    store\includes\modules\pages\account_edit\header_php.php carrier will be including in the fields array;
    telephone number must be exactly 10 digits
    includes\languages\english.php carrier labels and telephone format
    includes\languages\spanish.php
    Note: Changing the jscript to do the error checking didn’t seem to make any difference so I’m not even sure if that code is called. Thus the server side error checking seemed to be the only error checking that was triggered when I tested the code.


    Changes that I made to the zen_cart code (and that I’ll need to incorporate into upgrades):
    1. To create the code on checkout_success and send the sms text message to user:
    a. Added 6 fields to zen_orders_products table:
    ALTER TABLE `zen_orders_products` ADD `code` VARCHAR( 20 ) NOT NULL AFTER `products_id` ,
    ADD `downloaded` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `code` ,
    ADD `cntTries` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `downloaded` ,
    ADD `t_lastAccessed` TIMESTAMP NULL AFTER `cntTries` ;
    ADD `t_ordered` TIMESTAMP NULL AFTER ` t_lastAccessed ` ;
    ADD `t_downloaded` TIMESTAMP NULL AFTER `t_ordered` ;

    b. modified store/includes/modules/pages/checkout_success/header.php
    1. SQL for text messaging:
    SELECT customers_telephone, sms
    FROM zen_customers, carrier
    WHERE customers_id =2
    AND zen_customers.carrier_id = carrier.carrier_id

    c. Added carrier table:

    CREATE TABLE `carrier` (
    `carrier_id` int(11) NOT NULL auto_increment,
    `countries_id` int(11) NOT NULL default '0',
    `name` varchar(30) NOT NULL default '',
    `sms` varchar(30) NOT NULL default '',
    PRIMARY KEY (`carrier_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=1 ;

    d. Added 4 US carriers that support java apps to the table.
    e. Modified the customers table to add the carrier_id. Looked through store/admin functionality. There doesn’t appear to be any way to use this interface to add customer details—only to turn them off.

    2. To add carrier to registration information:
    a. Added function, zen_get_carrier_list, to store/includes/functions/html_output.php:

    /*
    * Creates a pull-down list of carriers
    */
    function zen_get_carrier_list($name, $selected = '', $parameters = '') {
    $carriers_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
    $carriers = zen_get_carriers();

    for ($i=0, $n=sizeof($carriers); $i<$n; $i++) {
    $carriers_array[] = array('id' => $carriers[$i]['carrier_id'], 'text' => $carriers[$i]['name']);
    }

    return zen_draw_pull_down_menu($name, $carriers_array, $selected, $parameters);
    }
    b. Modified store/includes/functions/functions_lookups.php by copying function get_countries() to get_carriers()
    c. Modified these 2 documents to change the text displayed “Additional Contact Details” to “Phone Number of Your Mobile Device (required to download mobile applications):
    1. F:\htdocs\edufone\store\includes\languages\english.php
    2. F:\htdocs\edufone\store\includes\languages\spanish.php
    d. Also added carrier label to the above documents

    Changes to templates that should stay between releases:

    e. Added code to display list of carriers: store/includes/templates/myTemplates/templates/tpl_modules_create_account.php
    f. Couldn’t find a way to add carrier to customer details, thus add to db table directly:
    SELECT *
    FROM `zen_configuration`
    WHERE `configuration_key` LIKE '%SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY%'
    LIMIT 0 , 30

    Thus I can add, SHOW_CREATE_ACCOUNT_DEFAULT_CARRIER, to zen_configuration file and give it the configuration_group_id of 5.
    g. configuration_id of country is 128. Thus, I’ll copy its values to a new configuration

    INSERT INTO `zen_configuration` ( `configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function` )
    VALUES (
    NULL , 'Create Account Default Carrier ID', 'SHOW_CREATE_ACCOUNT_DEFAULT_CARRIER', '1', 'Set Create Account Default Carrier ID to:<br />Default is 1', '5', '6', NULL , '0001-01-01 00:00:00', 'zen_get_carrier_name', 'zen_cfg_pull_down_carrier_list_none('
    );

    Carrier configuration id = 503

    h. Modified this file to add zen_cfg_pull_down_carrier_list_none function.
    zen_cfg_pull_down_country_list_none


    /home/content/b/e/a/bearBud2206/html/store/admin/includes/functions/general.php

    Line #903 : function zen_cfg_pull_down_country_list_none($country_id, $key = '') {

    ??? This file also has other country functions such as function zen_get_country_name($country_id) , and function zen_get_country_name_cfg(). I’m not adding those for carrier yet—see if I need them. They’re used on the admin side.

    i. Modified verification code in 2 places:
    1. /home/content/b/e/a/bearBud2206/html/store/includes/modules/pages/create_account/jscript_form_check.php
    Line #128 : check_select("country", "", "<?php echo ENTRY_COUNTRY_ERROR; ?>");
    to add similar verification for carrier.
    2. store/includes/form_check.js.php:
    check_select("carrier", "", "<?php echo ENTRY_CARRIER_ERROR; ?>");

    Now deal with updates. If the user needs to change his phone number/carrier.
    j. When checking out, let the user change them:
    added phone number and carrier to: store/includes/templates/myTemplate/tpl_modules_checkout_new_address.php
    k. When user edits his account info, add carrier: https://www.edufone.com/store/index....e=account_edit. Copy to myTemplates/templates and modify: F:\htdocs\edufone\store\includes\templates\myTemplate\templates\tpl_account_edit _default.php

    Problem with this code, unexpected ,:
    <!--highlight the user's carrier-->
    <label class="inputLabel" for="carrier"><?php echo ENTRY_CARRIER; ?></label>
    <?php
    $selected_carrier = ($_POST['carrier']) ? $account->fields['carrier_id'], 'id="carrier"') . (zen_not_null(ENTRY_CARRIER_TEXT) ? '<span class="alert">' . ENTRY_CARRIER_TEXT . '</span>': '');
    ?>
    But w/o this code, the user’s changes are not saved to the db.
    l. Also modified this file, F:\htdocs\edufone\store\includes\modules\pages\account_edit\header_php.php so the carrier will be including in the fields array:

    [fields] => Array
    (
    [customers_gender] => f
    [customers_firstname] => Jade
    [customers_lastname] => Lindquist
    [customers_dob] => 0001-01-01 00:00:00
    [customers_email_address] => support AT edufone DOT com
    [customers_telephone] => 5122807711
    [customers_fax] =>
    [customers_email_format] => HTML
    [customers_referral] =>
    )
    Didn’t have time to find code to set user’s current carrier selection. Will do that later.

    Problem, when creating new account, carrier is set to default vs. the one the user selected.
    Editing this file, fixed it: store/includes/modules/create_account.php

  5. #5
    Join Date
    Aug 2004
    Posts
    1,590
    Plugin Contributions
    1

    Default Re: Adding fields to customer details-- 2 questions

    You might want to try out the additional customers fields from my signature to facilitate the task.

  6. #6
    Join Date
    Jun 2009
    Location
    Orange County, California
    Posts
    544
    Plugin Contributions
    18

    Default Re: Adding fields to customer details-- 2 questions

    Here's a link to a module for just this!

    http://www.zen-cart.com/index.php?ma...oducts_id=1694

 

 

Similar Threads

  1. customer details fields
    By darksaviour69 in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 3 Aug 2010, 11:34 AM
  2. Adding new fields to the Customer Details
    By dustyshoes in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 30 Jul 2010, 08:24 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