Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding Custom Fields to Customer Details


Guest

Recommended Posts

I have decided to tackle this one on my own. Go HERE to get it

 

Admin Notes v1.0

 

Works great!

 

very interesting! well done.

 

how do you think it is possible to interface it or sync what you've done with MS outlook for instance! since a mail client like outloo is in common use it might be helpful to be able to synchronize with it. jus a thought!

Did you try? Did you fail? No matter! Try again. Fail again! But fail better!

Link to comment
Share on other sites

  • Replies 84
  • Created
  • Last Reply

Actually, I do not know. I know nothing about MS Outlook. I use MS Outlook Express.

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

  • 5 months later...

If i were to add fields like Pet Name, Pet Name2, Pet Name3, Pet Breed, Pet Species, how would the code look like in create_account.php, i cant seem to figure this part out, sorry , it's getting late over here :'(

Thanks in advance

RG

Link to comment
Share on other sites

  • 3 weeks later...

Hey all--

 

I've gone ahead and added about five extra fields to the customer info. However, how do I get this info to show up in the Order Confirmation E-mail that gets sent to both the customer and the store admin? Any help would be MUCH appreciated! Thanks,

 

Brian

Link to comment
Share on other sites

Hey..that is exactly what I just did for my store, but I lumbered through and figured it out without your great instructions.

However, now I want to split up the customer details in create account so it is over 2 pages. I'm a bit nervous about trying, as I know the basics in SQL and a very very little php. If I just make it two pages will I loose the info on the first page?

Do I need a submit button on each page, or can I pass along the info with a continue button, and only have the info on the 2nd page.

What if I want to let them have an option of submitting after the first page, or going on to the 2nd page?

That's what I'm about to tackle. If you have any great advice I'm all ears!

Julie

Link to comment
Share on other sites

Hey..that is exactly what I just did for my store, but I lumbered through and figured it out without your great instructions. 

However, now I want to split up the customer details in create account so it is over 2 pages.  I'm a bit nervous about trying, as I know the basics in SQL and a very very little php.  If I just make it two pages will I loose the info on the first page?

Do I need a submit button on each page, or can I pass along the info with a continue button, and only have the info on the 2nd page. 

What if I want to let them have an option of submitting after the first page, or going on to the 2nd page? 

That's what I'm about to tackle.  If you have any great advice I'm all ears!

Julie

 

 

Use a continue button to load the 2nd page and save all the filled in form fields as hidden fields, then when they submit that page, all the form fields will be passed on to the account.

L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Link to comment
Share on other sites

Use a continue button to load the 2nd page and save all the filled in form fields as hidden fields, then when they submit that page, all the form fields will be passed on to the account.

 

That is exactly what I'm thinking, and I know this is probably a dumb questiion, but do I replace the continue button which is a submit button

 

 

<?php echo tep_draw_separator('pixel_tranphp echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>

<td width="10">

WITH

 

<?php echo '<a href="' . tep_href_link(FILENAME_CREATE_MEASURE, '', 'SSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?>

 

Will the values from the Create_Account.php feed into the create_measure.php page?

 

Its the coding I'm not sure of....veeerrry sketchy on the PHP.

 

Oh..and what about this piece of code

 

tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

 

tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));

Does that need to be altered also?

 

Thanks

Julie

Link to comment
Share on other sites

  • 3 weeks later...

Thanks for this code, It works great!, below your quote is how I added TEXT to the right of the inputs for the admin like on the customer forms:

 

5. Open up catalog/admin/customers.php

 

<snip>

 

One thing we are missing though is the cms after the field. This is simply because I haven't figured out how to get that text in there.? Once again, we'll have to consult a PHP guy.

 

5. Open up catalog/admin/customers.php

 

Replace:

<?php
?if ($processed == true) {
? ?echo $cInfo->customers_fax . tep_draw_hidden_field('customers_fax');
?} else {
? ?echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'maxlength="32"');
?}
?>

 

with

<?php
?if ($processed == true) {
? ?echo $cInfo->customers_height . tep_draw_hidden_field('customers_height');
?} else {
? ?echo tep_draw_input_field('customers_height', $cInfo->customers_height, 'maxlength="3"' . 'style="width: 50"');
?}
?echo ' <span class="fieldRequired">' . ENTRY_CENTIMETERS_TEXT . '</span>'; ?>

Link to comment
Share on other sites

Anybody knows how to add custom field with selection of one of three radiobuttons?

 

and how to add search by letters if I want to display the whole alphabet?

Link to comment
Share on other sites

Anybody knows how to add custom field with selection of one of three radiobuttons?

 

and how to add search by letters if I want to display the whole alphabet?

 

I'm not a php person, but I just added custom fields with a drop down using

this contribution

 

http://www.oscommerce.com/community/contri...ll/search,title

 

You could probably modify it easily for the radio buttons. Its a little more complicated than using text because the field needs to have its own table.

As far as the alphabet thing goes.. sorry. I've seen that feature alot on sites, and its very useful. If you find and answer, let me know!

Julie

Link to comment
Share on other sites

  • 1 month later...

1054 - Unknown column 'cvv_number' in 'field list'

 

insert into orders (customers_id, customers_name, customers_company, customers_street_address, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, cvv_number, issue_number, date_purchased, orders_status, currency, currency_value) values ('2', 'Edgar Fernandez', '', 'soga gorriga 1', 'concolo', 'caguas', '00725', 'puerto rico', 'Puerto Rico', '7874621580', '[email protected]', '1', 'Edgar Fernandez', '', 'soga gorriga 1', 'concolo', 'caguas', '00725', 'puerto rico', 'Puerto Rico', '1', 'Edgar Fernandez', '', 'soga gorriga 1', 'concolo', 'caguas', '00725', 'puerto rico', 'Puerto Rico', '1', 'Cash on Delivery', '', '', '', '', '', '', now(), '1', 'USD', '1.00000000')

 

[TEP STOP]

 

i added some customs fields as the tutorial instructed now im having this error...

Link to comment
Share on other sites

I got this error alot when I was adding my custom fields, and it was usually something easy like a spelling mistake. Make sure that you have added that field to the database. I'm not a php person, but that might be the first place to start.

Julie

Link to comment
Share on other sites

  • 2 weeks later...

hey guys!

i really have an odd problem with adding new custom fields in

the ACCOUNT_EDIT.php

 

they only work and update the database if i add:

 

$mpass = "hallo"

$muser = "hehe"

....-> DB update....

 

 

if i do it like that:

 

$mpass = tep_db_prepare_input($HTTP_POST_VARS['mpass']);

...

array('customers_firstname' => $firstname,

'customers_lastname' => $lastname,

'customers_email_address' => $email_address,

'customers_telephone' => $telephone,

'muser' => $muser,

'customers_fax' => $fax);

 

 

the database fields gettin' cleared.

I think that my fields are correct, but the $POST doesnt work.

these are my fields:

 

<?php echo tep_draw_input_field('muser', $account['muser']) . ' '.....

they display the database content, but on submit they loose it due to wrong update (of course with both empty!!)

 

what can i do?

thx Mark

Link to comment
Share on other sites

i tryed this it didnt work i know it was my mistake i could see it was going to work but god knows what i did wrong

 

Adding Custom Fields to Customer Details

 

So you need to know some extra info about your customers?  This tutorial will explain how to add extra text fields to Customer Details. I will be using the example of HEIGHT, but this can be changed to any piece of info you need to know. 

 

You will have to edit the following FIVE files:

 

catalog/create_account.php

catalog/account_edit.php

catalog/includes/languages/english.php

 

catalog/admin/customers.php

catalog/admin/includes/languages/english.php

 

So basically you add fields and commands to write to the database in the files, and add the text label (Height, Weight, etc.) in the language files.  You have to do the account_edit so your customers can ... edit their account ;), and in case you want to see/change their info in the Admin, you will have to change stuff in their too.

 

But first you will need to add a new field to the database in phpMyAdmin.  Click on customers, scroll down to the bottom and look for "Add New Field".  Add 1 field At End of Table. Enter "height" into the Field name, make sure VARCHAR is selected, and make the Length 3 (this could be any lenth, the default is 32 in oSc, but for my purposes height rarely exceeds 999cms ;)) Hit OKAY and you are done!

Now, here we go to the hard part:

1. Open up catalog/includes/languages/english.php

 

Add your category and your label text.  For this example I will be making a category called Sizing, with one entry called Height:

 

define('CATEGORY_SIZE', 'Sizing');

define('ENTRY_CUSTOMER_HEIGHT','Height');

 

Now, I wanted to put a little centimeters beside the field so people knew what kind of measure ments to put in.  So I added another define:

 

define('ENTRY_CENTIMETERS_TEXT', 'centimeters');

 

This can be ANY text you want.

 

SAVE

2. Open up catalog/create_account.php

 

What I did here was copy and paste an entire CATEGORY.  If you are looking in Dreamweaver, go to around line 500 until you see <?php echo CATEGORY_CONTACT; ?>.  Now copy this cell, the one above it (tep_draw_seperator), and the cell below it which contains a table that has telephone and fax info.  Then paste these three cells where you want your category to appear. 

 

Select the <?php echo CATEGORY_CONTACT; ?> and change it to <?php echo CATEGORY_SIZE; ?>

 

Then go one cell down and get rid of the Telephone cells.  Select the <?php echo ENTRY_FAX_NUMBER; ?> and change it to <?php echo ENTRY_CUSTOMER_HEIGHT; ?> There is your label done.

 

The next php block is for drawing the actual form field.  Change:

 

<?php echo tep_draw_input_field('fax') . ' ' . (tep_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?>

 

<?php echo tep_draw_input_field('height','','maxlength="3"' . 'style="width: 50"') . ' ' . (tep_not_null(ENTRY_CENTIMETERS_TEXT) ? '<span class="caption">' . ENTRY_CENTIMETERS_TEXT . '</span>': ''); ?>

 

So now the actual form is done.  Notice that I have put a character maxlength and a style width on the field?  Adjust these as you wish.  Also, notice that our centimeters text is going to fall in there real nice.  See the special CSS style I gave the centimeter text so it would look nice?

 

So that is the table are done, but we are going to have to make two more additions.

 

We are going to need to make a variable, so insert the following around LINE 45:

 ? ?$height = tep_db_prepare_input($HTTP_POST_VARS['height']);

Next search for

 $sql_data_array = array('customers_firstname' => $firstname,

Add in

'customers_height' => $height,

somewhere in the array.  There are TWO arrays, make sure that this is changed in only the first one.

 

Now whatever is written in the field will be entered into the database.

 

SAVE

3.Open up catalog/account_edit.php

 

Here we are going to pull the same trick as above and copy the "My Details" CATEGORY, then edit it to our needs.  On line 185 you will see <?php echo MY_ACCOUNT_TITLE; ?>, so basically copy that cell, the one above and the one below.  It is from about LINE 174 to LINE 243 in total. Then paste it in below. Again, delete all the unnecessary blocks except for the fax number.  Select the <?php echo ENTRY_FAX_NUMBER; ?> and change it to <?php echo ENTRY_CUSTOMER_HEIGHT; ?>. Label finished, now for the field.

 

Replace:

<?php echo tep_draw_input_field('fax', $account['customers_fax']) . ' ' . (tep_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?>

with

<?php echo tep_draw_input_field('height', $account ['customers_height'],'maxlength="3"' . 'style="width: 50"') . ' ' . (tep_not_null(ENTRY_CENTIMETERS_TEXT) ? '<span class="caption">' . ENTRY_CENTIMETERS_TEXT . '</span>': ''); ?>

 

There is your table done. Notice that the input field is retrieving info from the database?

 

Now to make it writable.  Add in your variable around LINE 30:

	$height = 

tep_db_prepare_input($HTTP_POST_VARS['height']);

 

Search for

$sql_data_array = array('customers_firstname' => $firstname,

and add in

'customers_height' => $height,

somewhere in the array. Make sure to do this only to the TOP one.

 

Next, search for

$account_query = tep_db_query

You will have to enter your database field name in here too, so it knows where to look to retrieve the customers data.  Here is an example of what MY query looks like:

$account_query = tep_db_query("select customers_gender, customers_firstname, customers_lastname, customers_dob, customers_email_address, customers_height, customers_telephone, customers_fax from "

 

All done.  Now the customer will be able to view their information in My Account, and update the values if they grow a few cms. ;)

 

SAVE

 

4. Open up catalog/admin/includes/languages/english.php

 

Okay, this one is easy. You just do here exactly what you did in step one and add these three chunks:

 

define('CATEGORY_SIZE', 'Sizing');

define('ENTRY_CUSTOMER_HEIGHT','Height');

define('ENTRY_CENTIMETERS_TEXT', 'centimeters');

 

SAVE

 

5. Open up catalog/admin/customers.php

 

This one gets a little tricky.  We are going to copy and paste the Contact CATEGORY, just like what we did to the files over in the catalog.  Then rename <?php echo ENTRY_FAX_NUMBER; ?> to <?php echo ENTRY_CUSTOMER_HEIGHT; ?>.

 

Now, the field is a little tricky.  Replace:

<?php
?if ($processed == true) {
? ?echo $cInfo->customers_fax . tep_draw_hidden_field('customers_fax');
?} else {
? ?echo tep_draw_input_field('customers_fax', $cInfo->customers_fax, 'maxlength="32"');
?}
?>

 

with

<?php
?if ($processed == true) {
? ?echo $cInfo->customers_height . tep_draw_hidden_field('customers_height');
?} else {
? ?echo tep_draw_input_field('customers_height', $cInfo->customers_height, 'maxlength="3"' . 'style="width: 50"');
?}
?>

 

A little different than what we have done before.  Notice the maxlength and the style width.

 

You will also notice the cInfo, don't worry I don't know what this is for either.  Hafta consult a php guy. 

 

One thing we are missing though is the cms after the field. This is simply because I haven't figured out how to get that text in there.  Once again, we'll have to consult a PHP guy.

 

In any case, the table is set up, now we have to do our database stuff again, so insert our variable at around LINE 30

$customers_height = tep_db_prepare_input($HTTP_POST_VARS[

'customers_height']);

 

Search for:

$sql_data_array = array('customers_firstname' => $customers_firstname,

 

and enter in below:

'customers_height' => $customers_height,

 

Remember to do this only on the top sql query.

 

Find the $customers_query and enter in c.customers_height.  Notice the difference from step 3.  Here is an example of what MY query looks like:

$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, c.customers_height, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from "

 

Now we are DONE!!!

SAVE!!!!

 

Adjust at will, put those 5 files on the server and give it a go.  All should be fine. 

 

Good luck!!

Link to comment
Share on other sites

it works just fine! but i realized you have to be really careful with the input fields, no mistakes or nothing will work ;)

yours, Mark

 

That's exacty it Mark. There are so many places that you have to list the variable, and if you cut and paste and forget to change one, it won't work. Plus you have to do it again on the edit account, and the admin..so there are alot of areas for an error.

Julie

Link to comment
Share on other sites

Can someone tell me if the extra fields that you ask the customer to fill in are viewable on their invoice or their order information or customer information?

 

if these extra fields are edited in the invoice.php as well, yes!

but you have to insert the same tags there as well - like the tag to get them from the DB

 

yours, mark

Link to comment
Share on other sites

On my check out shipping page, i have the Gift wrap mod installed, if i wanted to add the fields

- Is this for a male or female?

- What is the occassion?

- WHat do you wish the gift card to say?

 

would i do it the same way but only to the checkout shipping page? and what table would i edit in the DB to add these new fields?

 

I also need to have it shown on the Admin Orders Status Page and shown within the order confirmation email sent to both customer and store owner.

Link to comment
Share on other sites

  • 2 weeks later...
Is it possible to make something like this?

http://www.oscommerce.com/forums/index.php?act...t=0#entry711332

 

yes, i suppose its not a big deal.

just insert:

 

<tr><td class="main">Type:</td>

<td class="main"><select name="type" onchange="java script:swap_fields('create');"><option value="2">Firma</option><option value="4">Offentlig</option><option value="1" SELECTED>Privat</option></select></td></tr>

 

and the javascript command.

 

I WAS WONDERING, wheater you could use this for the type of account the customer would like to create.

if he only buys DOWNLOAD Products, he probably doesn't want to add all the shipping address stuff..

so maybe we could deactivate certain "field size checks"

 

thx! yours, Mark

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...