Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding Custom Fields to Customer Details


Guest

Recommended Posts

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.

 

 

Should i assume that you cannot put extra fields like the ones above on the check out page?

Link to comment
Share on other sites

  • Replies 84
  • Created
  • Last Reply
Sorry, which code do I need to add in the invoice.php?

How did you go with the added filed for the invoice. I am trying to do the exact same thing . I have tried adding the same fields but it doesnt seem to work.

 

did you get it to work? if so what did you add to invoice.php?

 

Q

Link to comment
Share on other sites

How did you go with the added filed for the invoice. I am trying to do the exact same thing . I have tried adding the same fields but it doesnt seem to work.

 

did you get it to work? if so what did you add to invoice.php?

 

Q

 

Yes...I would like to know this as well, Thanks!

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...

Hi was hoping somebody could help me.

 

Can anyone explain how I can add these new fields to the invoice, should have been straightforward but somehow I managed to mess it up and cant get them to show :/

 

Many Thanks

Link to comment
Share on other sites

  • 1 month later...

ok, lets try another one, I want the customer to be able to choose whether or not they would like to put in there middle initial can I do this by following the methods decribed?

Link to comment
Share on other sites

  • 2 weeks later...
Hi; I went through the steps but I got this error msgs; 1054 - Unknown column 'customers_CRN' in 'field list'

Can any one help??

 

Its been soooo long since I did this, but I do remember getting that error alot...

 

There are so many places that you can make a misspelling, or interchange the variable name with the wron thing . So..my suggestion would be look very carefuly at ever little change that you made.

Im my case it was always.... that. I added 22 custom fields...

The drop downs are a real treat!

Hope this helps.

Julie

Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...
  • 1 month later...

Hi Guys,

 

I'm new to php and have come across problem adding customer fields.

 

I'm getting:

 

 

Parse error: syntax error, unexpected T_DOUBLE_ARROW in ..............

 

I can't see that i'm doing anything wrong.

 

Any advise would great.

 

Thanks

Link to comment
Share on other sites

Hi Guys,

 

I'm new to php and have come across problem adding customer fields.

 

I'm getting:

Parse error: syntax error, unexpected T_DOUBLE_ARROW in ..............

 

I can't see that i'm doing anything wrong.

 

Any advise would great.

 

Thanks

 

 

Sorted......

Link to comment
Share on other sites

  • 7 months later...

Whew - from 2004.... I hope someone is still monitoring this thread... Keeping in mind that Im new to php.... I made these changes and the form worked well. But all kinds of other problems started happening... so I had to start from scratch and re-enter my whole shopping cart anew... (don't laugh at me please!) It took me days.

 

I thought it would be easier to simply change 'FAX NUMBER' to Reseller ID.... I don't need the customer's fax number. My thought was to

 

1 change the database column in the phpmyadin

2 go to the pages mentioned in this guide and every mention of change fax or fax number to customer id.

 

I also need to have the Customer ID REQUIRED so I think I can turn on "required" in the adm panel.

 

Can anyone tell me if this will work? Because I am a wholesaler - i need to have the state reseller id number to exclude taxes.

 

Please respond as soon as you can before I screw up this installation! or email me

 

tee hee...

 

pam

Link to comment
Share on other sites

  • 2 months later...

Since this forum has so little threads on creating a new field, I thought I'd tag onto this thread. :-"

 

I had changed the "Comment" field, throughout the checkout process, into storing the date for "ship at a later date" if the customer wanted to ship later.

Now, I've been told to add in a "Message" field! Rather than try to figure out what I had changed to put the "...later date" back to comments and THEN figure out how to insert an actual "ship at a later date" field, I think it'd be faster/easier to simply add a "Message" text field into the database. (whew) So, how would I go about this? Since I didn't actually add a field before, I have no idea what that takes or which files need to be edited.

 

Anyone have any idea which database I'd add a new Message field to and which files would have to be edited so the customer can enter a message on the checkout_shipping.php page and have it show up on the checkout_confirmation.php page as well as in the admin area so we notice it??

 

Thanks!!

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
Anybody have any idea how to get this info in the order email received?

 

I'm not exactly sure. But I think it goes something like this:

Customer goes through checkout

once confirmed the information goes over to the orders table (i still want to find out how so I can make a new table there and call from it)

Then in the orders.php file all this information is called from the table.

 

once I figure out (or get told) how I'll post it here.

 

If you want to put it in the email that they receive in needs to go in checkout_process. have a look at this forum post

Link to comment
Share on other sites

  • 2 weeks later...
Anybody have any idea how to get this info in the order email received?

 

Okay, I have a solution of sorts. Thanks to my friends Malcolm & Aaron.

 

BACKUP FIRST.

 

4 files need to be changed:

catalog/checkout_process.php

catalog/includes/classes/order.php

catalog/admin/orders.php

catalog/admin/includes/classes/order.php

 

I haven't looked at the invoice file because we don't need it. My theory is it would be similar to the orders.php file. (Don't quote me on that)

 

I didn't have any trailing text (cms in the example) after my field so that needs to be added. I had called my field vip_number (not customer_vip_number), so just change that as necessary. All line numbers used are from the original clean files.

 

SQL:

Make a field in your orders table, copying the field you put in the customers table. So now you have 2 fields in 2 tables that can get the same info.

 

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 wink.gif) Hit OKAY and you are done!

 

in catalog/checkout_process.php:

 

Find (around line 56):

  $sql_data_array = array('customers_id' => $customer_id,

 

Add Before:

	$vip_number_query = tep_db_query("select vip_number from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$vip_number_query_array = tep_db_fetch_array($vip_number_query);
$vip_number = $vip_number_query_array['vip_number'];

 

This is the database query. It is linked to the customer id number

 

Find (around line 95):

						  'currency_value' => $order->info['currency_value']);

 

Replace with:

						  'currency_value' => $order->info['currency_value'],
					  'vip_number' => $vip_number);

 

Find (around line 240):

  if ($order->content_type != 'virtual') {
$email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . 
				EMAIL_SEPARATOR . "\n" .
				tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";
 }

 

Replace with:

  if ($order->content_type != 'virtual') {
$email_order .= "\n" . EMAIL_TEXT_DELIVERY_ADDRESS . "\n" . 
				EMAIL_SEPARATOR . "\nEmail: " . "\n" . ENTRY_VIP_NUMBER_TEXT . $vip_number . "\n\n" .
				tep_address_label($customer_id, $sendto, 0, '', "\n") . "\n";
 }

This is the text you defined in the language file at the start. If you don't want the double space remove one of the \n. \n = New line.

 

Save

 

in catalog/includes/classes/order.php

 

Find (around line 35):

	  $order_query = tep_db_query("select customers_id, customers_name,

 

Somewhere in this section, before the from TABLE, put your field name. for example i put in vip_number after the last_modified:

... last_modified, vip_number from ...

 

Find (around line 66):

	  $this->customer = array('id' => $order['customers_id'],

I changed the last line (line 77) of this to:

							  'email_address' => $order['customers_email_address'],
						  'vip_number' => $order['vip_number']);

 

Save

 

This would now send the email with the custom field in the email.

 

The process is the same to see it on the admin side.

 

In catalog/admin/orders.php

 

Find (around line 27):

  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 

Add Before:

	$vip_number_query = tep_db_query("select vip_number from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customer_id . "'");
$vip_number_query_array = tep_db_fetch_array($vip_number_query);
$vip_number = $vip_number_query_array['vip_number'];

 

This is the same code as we put in checkout_process.php

 

Find (around line 138):

			  <tr>
			<td class="main" valign="top"><b><?php echo ENTRY_CUSTOMER; ?></b></td>
			<td class="main"><?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>'); ?></td>
		  </tr>

 

Because of the way we wanted it displayed i put the vip number next to the Customer: . I Replaced the above with the following, you might want to play with this to suit your needs.

			  <tr>
			<td class="main" valign="top"><b><?php echo ENTRY_CUSTOMER . $order->customer['vip_number']; ?></b></td>
			<td class="main"><?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>'); ?></td>
		  </tr>

 

Find (around line 356):

	  $orders_query_raw = "select o.orders_id, o.customers_name,

add in your field name in all three $orders_query_raw, mine was o.vip_number. this is the field that was created in the orders table.

 

OPTIONAL

Find (around line 376):

				<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $orders['customers_name']; ?></td>

 

Replace with:

				<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $orders['customers_name'] . ' -  ' . $orders['vip_number']; ?></td>

This adds a - and the field info to the top part of admin/orders.php. we did this so we could see it at a glance. example:

Customers Order Total Date Purchased Status

TJ Alderson - 1234 $10.00 28/11/2007 10:00:17 Received

 

Save

 

In catalog/admin/includes/classes/order.php

Find (around line 26):

	function query($order_id) {
  $order_query = tep_db_query("select 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, currency, currency_value, date_purchased, orders_status, last_modified from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
  $order = tep_db_fetch_array($order_query);

 

Add your field in the $order_query. I dumped it beside last_modified again:

... last_modified, vip_number from...

 

Find (around line 57):

							  'email_address' => $order['customers_email_address']);

Since I wanted it for the customer info I put it inside the $this->customer = array('name' => $order['customers_name'],

 

Replace with:

							  'email_address' => $order['customers_email_address'],
						  'vip_number' => $order['vip_number']);

 

Save and upload the 4 files.

 

Please note: I am not an expert, I know that it can be done differently (perhaps even better), this is what works for me. If this looks scary, go learn some more php and then come back. I don't think I can help with any problems, plus I should get back to work now. I tested this on a local version of oscommerce before I put it live.

Link to comment
Share on other sites

  • 2 months later...

I have added 8 new custom fields. but when customer fill out registration form they got this message

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Girth, Chest Girth, Yoke Width, Arm Length_left, Shirt Length, Wrist Girth_Left,' at line 1

 

insert into customers (customers_firstname, customers_lastname, customers_email_address, customers_telephone, customers_fax, Neck Girth, Chest Girth, Yoke Width, Arm Length_left, Shirt Length, Wrist Girth_Left, Waist Girth, Hip Girth, Upper Arm Girth_Left, customers_newsletter, customers_password, customers_gender, customers_dob) values ('Shahzad', 'Ansari', '[email protected]', '0300570579', '', '', '', '', '', '', '', '', '', '', '1', '2998ed57f0db503e808b347fa2d485a0:ec', 'm', '19800823')

 

[TEP STOP]

 

Many thanks,

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

This post was very helpful ... I had exactly this need and this seems to work fine so far. Does anyone know what might need to be changed to NOT allow the customer to update a couple of the newly added fields? I want to add a "membership level" field, and a "membership expires" date field.

 

I have mostly completed a working membership module for oscommerce, and I was afraid of changing the oscommerce code so did it without changing anything other than adding db tables and adding new php files (one change to the application_top.php file gets it included and working). It works fine, but it's a bit complicated and I have the opportunity to rewrite this for another customer - so I am going to fix it (I hope).

 

I would like to move the membership settings into the user model/table and just wanted to make sure that there wasn't anything else I needed to do when messing with the oscommerce base code.

 

Here is what I think I should do:

 

Follow all the instructions in this article, but when I get to step three I just change any of the code that refers to changing this information so it only displays it on the user page.

 

Anyone else see an issue with this? Is there anywhere else a user might be able to change/see their information?

 

Thanks for any help you can provide ... I will post my membership code once I have it cleaned up a bit.

Link to comment
Share on other sites

  • 1 month later...

OK I'm really stumped on this one now :( I've gone through the instructions a few times over to add a field named how_heard to the create_account.php page but I can't get any data from that field to go into the db. When I use the account_edit.php page, same thing exactly. If I manually enter something into the relevant database field and view that customer's record in account_edit.php, the data shows up in the right field but the db contents don't change if I then modify the contents of the field in that form. Basically it's not writing anything to the db from my new fields, but is reading back OK.

 

Here's what I've got so far which applies to this field:

 

* I've got a varchar(50) database field named: customers_how_heard

* The stuff at the top of the file includes: $how_heard = tep_db_prepare_input($HTTP_POST_VARS['how_heard']);

* The sql_data_array includes: 'customers_how_heard' => $how_heard,

* The account_query includes: customers_how_heard,

* The actual form field itself is formed by: <td class="main"><?php echo tep_draw_input_field('how_heard', $account['customers_how_heard']); ?></td>

 

As far as I can tell I've done exactly the same as 'fax' yet the info's only going one way. All the other fields work, so I could use the fax field for what I want instead, but I'd rather get it working properly than use a workaround. Ultimately I want to use radio buttons or a dropdown list but a text field will do to start with.

 

Any help greatly appreciated, thanks!

Greg

Link to comment
Share on other sites

  • 2 weeks later...

Hello All,

 

I am trying to add 'company_type' to my account info page. Got that working just fine..., but I can't get the 'company _type' to show up in my admin customer info.

 

I have been trying for the past MANY hours and have re-done the admin/customer.php page MANY times hoping to get it right, but no luck.....

 

Any help would be appreciated!

 

Chantal >_<

Link to comment
Share on other sites

  • 3 months later...

This was a really good tutorial. Thankyou.

 

 

How would i make this a drop down menu with a large selection (10-20) options, instead of a text input field???

 

 

Please can someone help with this...I have made it place a drop down menu inplace of the text field which is now blank, i just need to know how to link it to a list of options using the database.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...