Jump to content
Sign in to follow this  
kit

Customers extra fields

Recommended Posts

Cool contrib :thumbsup:

The only problem is that I can't see my extra fields in checkout_shipping_address.php and checkout_payment_address.php.I have many customers who have different addresses for payment and shipping...It will be to nice to have some kind of option to choose the address in this pages so the customers don't have to imput every time all the fields :-"


Cumparaturi4all

Share this post


Link to post
Share on other sites
Cool contrib :thumbsup:

The only problem is that I can't see my extra fields in checkout_shipping_address.php and checkout_payment_address.php.I have many customers who have different addresses for payment and shipping...It will be to nice to have some kind of option to choose the address in this pages so the customers don't have to imput every time all the fields :-"

 

 

found another interesting contrib for a quick address changing on checkout Easy Address Change During Checkout

 

 

now working on adding extra fields to checkout_shipping_address.php and checkout_payment_address.php :'(


Cumparaturi4all

Share this post


Link to post
Share on other sites

"PHP is not forgiving. You need to follow, step by step. "

 

Don't I know it.

 

Cheers, guys! I'll give it another crack.

Share this post


Link to post
Share on other sites

First, great contribution. Thanks :)

 

I also added this contribution http://www.oscommerce.com/community/contributions,3737 (which works great, kudos)

 

My question is:

 

1. I need for the extra pages to show up on checkout_shipping.php (where customer is able to edit just as in acount_edit.php)

 

2. After i click continue or proceed to checkout_payment.php, it should update the extra fields accordingly in the db table "customers_to_extra_fields"

 

So basically the idea is for the customer to be able to update the extra fields in checkout_shipping.php without having to go back to account_edit.php and of course, the most current edits to show up in the confirmation email.

 

Any help is greatly appreciated.

 

Thank you

Share this post


Link to post
Share on other sites
First, great contribution. Thanks :)

 

I also added this contribution http://www.oscommerce.com/community/contributions,3737 (which works great, kudos)

 

My question is:

 

1. I need for the extra pages to show up on checkout_shipping.php (where customer is able to edit just as in acount_edit.php)

 

2. After i click continue or proceed to checkout_payment.php, it should update the extra fields accordingly in the db table "customers_to_extra_fields"

 

So basically the idea is for the customer to be able to update the extra fields in checkout_shipping.php without having to go back to account_edit.php and of course, the most current edits to show up in the confirmation email.

 

Any help is greatly appreciated.

 

Thank you

 

I figured out a way to get this to work.

 

Thanks.

Share this post


Link to post
Share on other sites
I figured out a way to get this to work.

 

Thanks.

 

will you outline how you got this to work?

 

and how can I get these extra fields to show up on the order edit or invoice page?

Share this post


Link to post
Share on other sites
I'm glad insomniac2 jumped on this ... I'll have to see about the email part as there is already an update for emailing (that works for me, at least). Anyways ... here's the first draft of some code to get the invoice to print the extra fields. As insomniac2 mentioned, we have enough code in this contribution to help generate the extra fields almost anywhere, although I believe it was only missing the invoice integration. Everything else (add/edit forms, etc) should be easier and I'll get working on Order Editor.

 

Below I tried to mimic the structure used within osC without changing anything, per se. I wanted to simply get an extra piece of information into queries that are already being run. Then use that extra "id" info for tying together orders/customers/extra_fields, etc.

  • FILE: admin/includes/classes/order.php
  • LINE ~13
  • NOTE- We need to add a variable to hold our extra fields info.

FIND:

  class order {
var $info, $totals, $products, $customer, $delivery, $content_type;

function order($order_id = '') {
	  $this->info = array();

REPLACE:

  class order {
var $info, $extra_fields, $totals, $products, $customer, $delivery;

function order($order_id) {
	  $this->info = array();
	  $this->extra_fields = array();

  • FILE: admin/includes/classes/order.php
  • LINE ~28
  • NOTE - The only change for the following find/replace is the addition of "customers_id" to the order_query.

FIND:

$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. "'");

 

REPLACE:

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

  • FILE: admin/includes/classes/order.php
  • LINE ~48
  • Only added 'cust_id' => $order['customers_id'], to the "$this->customer = array" -- don't forget the comma.

$this->customer = array('cust_id' => $order['customers_id'],
	'name' => $order['customers_name'],
			'company' => $order['customers_company'],
	   	'street_address' => $order['customers_street_address'],
			'suburb' => $order['customers_suburb'],
			'city' => $order['customers_city'],
			'postcode' => $order['customers_postcode'],
			'state' => $order['customers_state'],
			'country' => $order['customers_country'],
			'format_id' => $order['customers_address_format_id'],
			'telephone' => $order['customers_telephone'],
			'email_address' => $order['customers_email_address']);

  • FILE: admin/invoice.php
  • NOTE - This output is its own table that can be placed above the "Comments" on the invoice.php. Seeing how there are a number of different invoice layouts available, then I suggest plugging this in above the comments section and below the products. Otherwise just take your time and work with the formatting.

<!-- PRINT EXTRA FIELDS CODE STARTS HERE //-->
<?php 
$orders_extrafields_query = tep_db_query("SELECT DISTINCT o.customers_id, cte.value, efi.fields_name, o.customers_name FROM " 

.TABLE_EXTRA_FIELDS_INFO. " efi INNER JOIN " .TABLE_CUSTOMERS_TO_EXTRA_FIELDS. " cte ON (efi.fields_id = cte.fields_id) INNER JOIN " 

.TABLE_ORDERS. " o ON (cte.customers_id = o.customers_id) WHERE (efi.languages_id = '".$languages_id."') AND (o.customers_id ='". 

tep_db_input($order->customer['cust_id']) ."') ORDER BY cte.fields_id ASC");

	if (tep_db_num_rows($orders_extrafields_query)) {
		$has_extrafields = false;
		echo '		<tr>';
		echo '		  <td width="95%">' . tep_draw_separator('pixel_trans.gif', '1', '7') . '</td>';
		echo '		</tr>';			
		echo '	<table width="95%" width="100%" border="0" cellpadding="0" cellspacing="0" class="main">';
		echo ' 		<tr>';
		echo '	 		<td><strong>' . TABLE_HEADING_EXTRAFIELDS . ':</strong><br><br></td>';
		echo '	 	</tr>';

		while ($orders_extrafields = tep_db_fetch_array($orders_extrafields_query)) {
			if (tep_not_null($orders_extrafields['value'])) {
				$has_extrafields = true;// Not Null = Has Extra Fields
				if (tep_not_null($orders_extrafields['value'])) {
					$exInfo = new objectInfo($orders_extrafields);
					echo '<tr>';
					echo '	<td width="95%">';
					echo '		<strong>' . nl2br(tep_db_output($orders_extrafields['fields_name'])) 

.':</strong><br /><span class="smallText">' . nl2br(tep_db_output($orders_extrafields['value'])) . '</span><br /><br />';
					echo '	</td>';
					echo '</tr>';			

				}
			}
		}
		 if ($has_extrafields == false) { /*most of this stuff is row-to-row ending the section (with a FINAL row to end the table) */
			echo '		<tr>';
			  echo '		  <td>' . tep_draw_separator('pixel_trans.gif', '1', '7') . '</td>';
			  echo '		</tr>';
		 }
			echo '		<tr>';
			  echo '		  <td>' . tep_draw_separator('pixel_trans.gif', '1', '7') . '</td>';
			  echo '		</tr>';
		 	echo '	</table>';
	}
?> 
<!-- PRINT EXTRA FIELDS CODE ENDS HERE //-->

 

How can I get this extra field(s) to show on the order edit page? The stock OSC order editor? Was this ever completed? THanks!

Share this post


Link to post
Share on other sites

Place this code where you want the extra fields to show up

 

 

 

<!-- START Customers Extra Field -->

 

<?php echo tep_get_extra_fields($customer_id, $languages_id)?>

 

<!-- END Customers Extra Field -->

 

 

 

 

 

Towards the top of the page, find the code that processess the action initiated by the (in my case continue button on checkout_shipping.php) "continue button".

 

Place the code below such that when the "continue button" is initiated, your customer extra field code is also run.

 

 

In my case, i placed the customer extra fields code after:

 

// process the selected shipping method

if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') ) {

if (!tep_session_is_registered('comments')) tep_session_register('comments');

if (tep_not_null($HTTP_POST_VARS['comments'])) {

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

}

 

 

 

//START Customers Extra Field

 

 

tep_db_query("delete from " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " where customers_id=" . $customer_id);

$extra_fields_query = tep_db_query("select ce.fields_id from " . TABLE_EXTRA_FIELDS . " ce where ce.fields_status=1 ");

while($extra_fields = tep_db_fetch_array($extra_fields_query)){

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

'fields_id' => $extra_fields['fields_id'],

'value' => $HTTP_POST_VARS['fields_' . $extra_fields['fields_id']]);

tep_db_perform(TABLE_CUSTOMERS_TO_EXTRA_FIELDS, $sql_data_array);

}

 

//END Customers Extra Field

Share this post


Link to post
Share on other sites
Customers Extra Fields EXTENDED by kit 15 Oct 2007

 

This addon created on basis of Customers Extra Fields v1.2a Rollup.

 

But it allow to add next types of extra fields:

 

1) Text (Standart)

2) Textarea (Standart)

3) Radiobuttons list

4) Multicheck list

5) Drop down menu

 

Kit, I hope you still read this topic. I have tried to install your contri, but what changed ???

I can't tell ...

 

Do you have update-instructions for me ??

Share this post


Link to post
Share on other sites
Place this code where you want the extra fields to show up

 

 

 

<!-- START Customers Extra Field -->

 

<?php echo tep_get_extra_fields($customer_id, $languages_id)?>

 

<!-- END Customers Extra Field -->

 

 

 

 

 

Towards the top of the page, find the code that processess the action initiated by the (in my case continue button on checkout_shipping.php) "continue button".

 

Place the code below such that when the "continue button" is initiated, your customer extra field code is also run.

 

 

In my case, i placed the customer extra fields code after:

 

// process the selected shipping method

if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') ) {

if (!tep_session_is_registered('comments')) tep_session_register('comments');

if (tep_not_null($HTTP_POST_VARS['comments'])) {

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

}

 

 

 

//START Customers Extra Field

 

 

tep_db_query("delete from " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " where customers_id=" . $customer_id);

$extra_fields_query = tep_db_query("select ce.fields_id from " . TABLE_EXTRA_FIELDS . " ce where ce.fields_status=1 ");

while($extra_fields = tep_db_fetch_array($extra_fields_query)){

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

'fields_id' => $extra_fields['fields_id'],

'value' => $HTTP_POST_VARS['fields_' . $extra_fields['fields_id']]);

tep_db_perform(TABLE_CUSTOMERS_TO_EXTRA_FIELDS, $sql_data_array);

}

 

//END Customers Extra Field

 

Cool stuff :thumbsup:

But how do I add this to checkout_payment_address.php ? :blush:

I am new at this php stuff and the above code doesn't apply to checkout_payment_address.php.

Thanks


Cumparaturi4all

Share this post


Link to post
Share on other sites
Cool stuff :thumbsup:

But how do I add this to checkout_payment_address.php ? :blush:

I am new at this php stuff and the above code doesn't apply to checkout_payment_address.php.

Thanks

 

BACK UP YOUR FILE BEFORE YOU DO THIS IN CASE YOU HAVE TO REVERT BACK

 

 

1. LOOK FOR:

 

// process a new billing address

if (tep_not_null($HTTP_POST_VARS['firstname']) && tep_not_null($HTTP_POST_VARS['lastname']) && tep_not_null($HTTP_POST_VARS['street_address'])) {

$process = true;

 

2. AFTER THIS, IN A NEW LINE, ADD:

 

//START Customers Extra Field

 

 

tep_db_query("delete from " . TABLE_CUSTOMERS_TO_EXTRA_FIELDS . " where customers_id=" . $customer_id);

$extra_fields_query = tep_db_query("select ce.fields_id from " . TABLE_EXTRA_FIELDS . " ce where ce.fields_status=1 ");

while($extra_fields = tep_db_fetch_array($extra_fields_query)){

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

'fields_id' => $extra_fields['fields_id'],

'value' => $HTTP_POST_VARS['fields_' . $extra_fields['fields_id']]);

tep_db_perform(TABLE_CUSTOMERS_TO_EXTRA_FIELDS, $sql_data_array);

}

 

//END Customers Extra Field

 

 

3. AROUND LINE 407, LOOK FOR:

 

if ($addresses_count < MAX_ADDRESS_BOOK_ENTRIES) {

 

4. AFTER THIS, IN A NEW LINE, ADD:

 

<tr>

<td>

<!-- START Customers Extra Field -->

 

<?php echo tep_get_extra_fields($customer_id, $languages_id)?>

 

<!-- END Customers Extra Field -->

</td>

</tr>

Edited by a_khan69

Share this post


Link to post
Share on other sites

In Admin, when you check an order details you can view stuff like customer information phone/name/etc... These are fields that the customer can fill in when creating an account.

 

How can I display what a customer entered for the extra fields in the orders detail page (orders.php)????

 

For instance, when I create my extra field say ("how did you hear about us") I want to display what the customer entered on the order page.

 

Any ideas?

Share this post


Link to post
Share on other sites

I get error message when updating database in PhpMyadmin:

 

 

CREATE TABLE customers_to_extra_fields(

customers_id int( 11 ) NOT NULL default '0',

fields_id int( 11 ) NOT NULL default '0',

`value` text

) ENGINE = MYISAM DEFAULT CHARSET = utf8;

 

MySQL 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 'DEFAULT CHARSET=utf8' at line 5

 

Can someone help me?! Thanks

Share this post


Link to post
Share on other sites

Today I was adding to Customer Extra Field last contr named Customers Extra Fields EXTENDED

 

I find a problem:

 

In admin/customers.php there isn't following code

<tr>

<td class="formAreaTitle"><?php echo CATEGORY_OPTIONS; ?></td>

</tr>

 

so I don't know if i can add code :huh:

<?echo tep_get_extra_fields($cInfo->customers_id,$languages_id)?>

 

The same problem, in the same file admin/customers.php in searching

if ($error == false) {

 

I don't find it !!!

 

Doing this contribution by myself is rather impossible for me, I'm still new in programming php. :blush: it will take month or years to me!

 

Can you help me? I will be grateful to you. :D

Edited by western

Share this post


Link to post
Share on other sites

SORRY! :blush:

 

With my old dreamWeaver 2004 I opened a different file with the same name. Please pardon me,

 

IT'S ALL OK!

 

Thank you for your contrib! You're fantastic!!!!

 

I'll soon made my contrib and put them here. When I'll know more about Php.

Now your help was really important to me.

 

Thank you!!! :D :thumbsup:

Edited by western

Share this post


Link to post
Share on other sites

Hi and thanks for this contribution. Just installed latest extra fields extended and would like to report few minor issues that perhaps could be fixed in the next release:

 

1. mysql stric mode --- "1366 - Incorrect integer value: 'on' for column"

2. administration -- 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 '' at line 1

global languages_id in not read ... fixed it for now by adding to extra_field_query in admin/general.php TABLE_LANGUAGES

3. when a customer is deleted the info regarding his extra fields in customer_to_extra_fields table is not deleted

4. a field must be chosen (phisically checked in) while creating it. Default value does not seem to work very well

 

Thanks again


/e

Share this post


Link to post
Share on other sites

multi checkboxes cause Warning: in_array() in the following function (general.php)

 

$extra_fields_string .= tep_draw_selection_field('fields_' . $extra_fields['fields_id'] . '_' . ($cnt++), 'checkbox', $item, ((in_array($item, $value_list))?(true):(false))).$item. (($extra_fields['fields_required_status']==1) ? '<span class="inputRequirement">*</span>': '').'<br>';

 

fix: replace the string with the one in catalog/functions/general.php


/e

Share this post


Link to post
Share on other sites

i am look forward if it is possible to add picture in this contrib too.... for the field that i wanna add needs picture to explain what needs to be filled .... for example ....... :-" what is the smiley doing <whistling>

Share this post


Link to post
Share on other sites

This script works great. One questions that I did not see, how would add this information on to the account_history_info.php? I tried a few things but I think I need a SQL string to bring in the information.

 

Dan

Share this post


Link to post
Share on other sites

Hi

 

Great Contribution - should save a lot of time. Only problem is I'm using it alongside pay without account, in addition I only have pay without account active. When the customer buys a customer account is never actually created, I therfore need to post the extra field info into admin/orders.php somehow.

 

My knowledge of php is limited at best is there anyone out there would know how to do this?

 

Cheers

Share this post


Link to post
Share on other sites
I figured out a way to get this to work.

 

Thanks.

 

Hi,

 

Can you share how you got this to work? You can PM me, but it would also be good for others to see what you did.

 

Thanks for your help.

 

Erick

Share this post


Link to post
Share on other sites

Hi, find error:

 

Parse error: syntax error, unexpected '<' in /home/mycoo1/public_html/test/generalmerchandise/admin/includes/filenames.php on line 51

 

Can anyone help me to fix it up?

Share this post


Link to post
Share on other sites

problem fixed.

but got new error:

 

 

Warning: Cannot modify header information - headers already sent by (output started at /home/mycoo1/public_html/test/generalmerchandise/admin/includes/languages/english.php:309) in /home/mycoo1/public_html/test/generalmerchandise/admin/includes/functions/general.php on line 18

Share this post


Link to post
Share on other sites
Anyone know how to combine it with purchase without account?

 

 

I am also having the same problem, has anyone worked out a solution for this yet?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×