Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

beta release extra questions


nana

Recommended Posts

this contribution lets you ask up to 5 questions either when customer is creating an account or checking out or after the purchase is made.

you can choose from input field drop_down ckbox or radio botton

all adjustments are made in the admin section

please test and report the bugs here

i have to start this tread so i can put the info in the contribution section

i will add the contribution soon

Link to comment
Share on other sites

  • Replies 84
  • Created
  • Last Reply

Top Posters In This Topic

it seems that i have made a mistake

please run this in your sql file if you are having a miissing field error

drop table if exists questions;
CREATE TABLE questions (
 source_id int NOT NULL auto_increment,
 sources_name varchar(64) NOT NULL,
 question_number int(4) NOT NULL,
 PRIMARY KEY (source_id),
 KEY IDX_SOURCES_NAME (sources_name)
);

INSERT INTO questions VALUES (1, 'Google',1);
INSERT INTO questions VALUES (2, 'Yahoo!',1);
INSERT INTO questions VALUES (3, 'AOL',1);
INSERT INTO questions VALUES (4, 'MSN',1);
INSERT INTO questions VALUES (5, 'osCommerce',1);

Link to comment
Share on other sites

Frank,

So far, this is working on my dev site with a few small issues. The required asterisks appear even when I have the required turned off for a question. Either way, they don't seem to pop an error for required when they're not filled out. Also, the answers don't appear in checkout_confirmation for me.

Request: How do I get the answers to appear in the e-mails and a customer's order history?

Link to comment
Share on other sites

  • 2 weeks later...

I'm a little confused on installation. Under part A on new files to upload you have this listed:

 

* includes/languages/english/extra_questions.php

 

However, I can't find and extra_questions.php under includes/languages/englishenglish. I found the one for admin. Are they the same file?

 

I also noticed a file includes/languages/questions_english.php but it doesn't have any instruction on what to do with it.

 

I was wondering if anyone has some clarification on installation of the contrib.

 

Thanks in advance.

Shade and Sweet Water

Chris Czerniak

Link to comment
Share on other sites

Ok, I have it installed and almost working. I just can't get it to output to order.php. I check and it is updating the database with my new questions. In order.php it shows "First Question" where I want but never outputs a value.

 

Any ideas?

Shade and Sweet Water

Chris Czerniak

Link to comment
Share on other sites

dan i have sent you a modified version of extra_questions_show_box.php

and extra_questions_upload_result_box.php that i think resolved the red * issue but you can use the one in the latest version. just make a copy of the ones you have incase

chris

use this for admin/display_answer_box.php

<?php
$extra_questions_query = tep_db_query("select first_answer,second_answer,third_answer, fourth_answer,fifth_answer from " . TABLE_ANSWERS . " where location_id = '" . (int)$oID . "'and location='" .QUESTION_LOCATION . "'" );
$extra_questions = tep_db_fetch_array($extra_questions_query);


 if (DISPLAY_FIRST_QUESTION == 'true') {
?>	 
		  <tr>
			<td class="main"><b><?php echo FIRST_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['first_answer']; ?></td>
		  </tr>

<?php
}
 if (DISPLAY_SECOND_QUESTION == 'true') {
?>
		   <tr>
			<td class="main"><b><?php echo SECOND_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['second_answer']; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_THIRD_QUESTION == 'true')  {
?>
		   <tr>
			<td class="main"><b><?php  echo THIRD_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['third_answer']; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_FOURTH_QUESTION == 'true') {
?>
		  <tr>
			<td class="main"><b><?php echo FOURTH_TITLE; ?></b></td>
			<td class="main"><?php  echo $extra_questions['fourth_answer']; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_FIFTH_QUESTION == 'true')  {
?>
		  <tr>
			<td class="main"><b><?php  echo FIFTH_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['fifth_answer']; ?></td>
		  </tr>

<?php
}


?>

Link to comment
Share on other sites

also you have to replace display_answer_after_order.php in the catalog folder to this

i can not get the logic for checkout_success question yet but i will post as soon as i have a solution for that

<?php
if ($display_answer== 1) {
$first_answer=$HTTP_SESSION_VARS['first_answer'];
$second_answer=$HTTP_SESSION_VARS['second_answer'];
$third_answer=$HTTP_SESSION_VARS['third_answer'];
$fourth_answer=$HTTP_SESSION_VARS['fourth_answer'];
$fifth_answer=$HTTP_SESSION_VARS['fifth_answer'];

if (QUESTION_LOCATION == 'account'){
$locID=$customers_id;

$extra_questions_query = tep_db_query("select first_answer,second_answer,third_answer, fourth_answer,fifth_answer from " . TABLE_ANSWERS . " where location_id = '" . (int)$locID . "'and location='" .QUESTION_LOCATION . "'" );
$extra_questions = tep_db_fetch_array($extra_questions_query);
$first_answer=$extra_questions['first_answer'];
$second_answer=$extra_questions['second_answer'];
$third_answer=$extra_questions['third_answer'];
$fourth_answer=$extra_questions['fourth_answer'];
$fifth_answer=$extra_questions['fifth_answer'];
}
if (QUESTION_LOCATION == 'orders'){
$first_answer=$HTTP_SESSION_VARS['first_answer'];
$second_answer=$HTTP_SESSION_VARS['second_answer'];
$third_answer=$HTTP_SESSION_VARS['third_answer'];
$fourth_answer=$HTTP_SESSION_VARS['fourth_answer'];
$fifth_answer=$HTTP_SESSION_VARS['fifth_answer'];
}}
?>
<tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php
 if (DISPLAY_FIRST_QUESTION == 'true') {
?>	 
		  <tr>
			<td class="main"><b><?php echo FIRST_TITLE; ?></b></td>
			<td class="main"><?php echo $first_answer; ?></td>
		  </tr>

<?php
}
 if (DISPLAY_SECOND_QUESTION == 'true') {
?>
		   <tr>
			<td class="main"><b><?php echo SECOND_TITLE; ?></b></td>
			<td class="main"><?php echo $second_answer; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_THIRD_QUESTION == 'true')  {
?>
		   <tr>
			<td class="main"><b><?php  echo THIRD_TITLE; ?></b></td>
			<td class="main"><?php echo $third_answer; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_FOURTH_QUESTION == 'true') {
?>
		  <tr>
			<td class="main"><b><?php echo FOURTH_TITLE; ?></b></td>
			<td class="main"><?php  echo $fourth_answer; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_FIFTH_QUESTION == 'true')  {
?>
		  <tr>
			<td class="main"><b><?php  echo FIFTH_TITLE; ?></b></td>
			<td class="main"><?php echo $fifth_answer; ?></td>
		  </tr>

<?php
}


?>
</table></td></tr></table></td></tr>

Link to comment
Share on other sites

Hi, Frank! Got this just about set now and I'm really tickled with it! You've done a great job on this and saved me weeks of random mucking with code. Thanks again! It's running smoothly on my dev store now with my slashed up checkout. Thanks for guidance on that, too! I was considering making it a Contrib, but it looks like you might be making FEC do these things already. Anyway, here's the dev store if you want to see your work as I've set it up. It will be up there for a couple of weeks anyhow.

The only change I want to make is to make the text box larger for the customer to input their gift message. I think it's set in the stylesheet to that size, but if you have any advice or thoughts, I'd sure appreciate it.

 

Oh, yeah. The links in the javascript slideshow are hard coded and will jump to the live store, so don't use them. Also, the only product currently in stock on the dev store is the special (white climbing rose on the right).

Edited by brushwood
Link to comment
Share on other sites

go ahead by all means if you want to make any contribution and code enhancment that you want you are probably more familiar with it than

and i want to keep fec as simple as possible you see that even as it is now it is a handfull i am at work so i will ck your store as soon as i get home

Link to comment
Share on other sites

chris use this for admin/display_answer_box.php

 

I replaced the code and it is doing the same thing. This is what my output screen looks like:

 

extra_quest_test.jpg

 

Where "extra_questions" appears is boxed in red. So, the title is appearing. And I checked the questions and answers tables and they are collecting data.

Edited by cczernia

Shade and Sweet Water

Chris Czerniak

Link to comment
Share on other sites

I love this contribution. It's easy to install, and work with, good job :)

 

I noticed that the required question messages appear on the top of the screen in a red bar instead of the pop-up menu like the rest of the required fields. A work-around is just simply makign it a drop down so the required portion isn't even necessary.

 

My main issue is that I get this error whenever I try to view/delete a customer in the OsCommerce control panel.

 

Warning: reset(): Passed variable is not an array or object in /admin/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /admin/includes/classes/object_info.php on line 18

 

Anyone encountered this / found a fix?

Edited by mwiznitzer
Link to comment
Share on other sites

mwiznitzer i have seen this problem with a lot of contributions and i think it has something to do with address book enteries not matching up with customers i do not remmember the solution but i am sure if you check for the mismatch between the two tables or do a search in the forum you will find the answer

 

 

 

Chris this is my display_answer_box.php right of the demo site

if it does not work please check the following

the location field is correct it checks only for matching location

i mean that if the location that the data is collected must matches the location when data is displayed

if you change from account to order after the questions are answered it will not show in the admin section

i would be glad to look at your site if you want to give me access to see if i can find the problem

 

<?php
$extra_questions_query = tep_db_query("select first_answer,second_answer,third_answer, fourth_answer,fifth_answer from " . TABLE_ANSWERS . " where location_id = '" . (int)$oID . "'and location='" .QUESTION_LOCATION . "'" );
$extra_questions = tep_db_fetch_array($extra_questions_query);


 if (DISPLAY_FIRST_QUESTION == 'true') {
?>	 
		  <tr>
			<td class="main"><b><?php echo FIRST_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['first_answer']; ?></td>
		  </tr>

<?php
}
 if (DISPLAY_SECOND_QUESTION == 'true') {
?>
		   <tr>
			<td class="main"><b><?php echo SECOND_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['second_answer']; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_THIRD_QUESTION == 'true')  {
?>
		   <tr>
			<td class="main"><b><?php  echo THIRD_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['third_answer']; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_FOURTH_QUESTION == 'true') {
?>
		  <tr>
			<td class="main"><b><?php echo FOURTH_TITLE; ?></b></td>
			<td class="main"><?php  echo $extra_questions['fourth_answer']; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_FIFTH_QUESTION == 'true')  {
?>
		  <tr>
			<td class="main"><b><?php  echo FIFTH_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['fifth_answer']; ?></td>
		  </tr>

<?php
}


?>

Link to comment
Share on other sites

Chris this is my display_answer_box.php right of the demo site

if you change from account to order after the questions are answered it will not show in the admin section

 

Actually I did change from account to after_order and then back to account. For the one entry I had on after_order I did see the answer but after switching back to account I havn't seen anything.

Edited by cczernia

Shade and Sweet Water

Chris Czerniak

Link to comment
Share on other sites

Ok, I ran into a new problem.

 

Now, for some reason that database is not recording "location_id" correctly. Instead it is just recording a "0." The entry with the first 0 for location_id is getting displayed in every admin order.

Shade and Sweet Water

Chris Czerniak

Link to comment
Share on other sites

Aye, thanks Frank. I had noticed an unsynced id scheme but I wasn't sure if that was it. I just re-installed, uploaded my modified files and its worked beautifully. Simple, thanks.

 

Another question, how feasible is it to add more than 5 questions?

Careful, Mitch. I'm sure Frank can do this but you risk a lot by asking too many questions during checkout. You've gotten them this far in the process (you're now down to a few percent of all of your visitors to the site). Every step you add or information bit you ask will lose you more customers. Cart abandonment studies prove this fact. I love this Contrib. I'm just careful not to abuse it. In fact I have taken important steps to shorten my checkout to compensate for the extra questions.

I'm not saying don't do it. Just be careful.

Link to comment
Share on other sites

hello, i'm a newbie here...

anyway thx for the contribution, its fantastic...

 

by the way, ihave a question regarding it..i added an extra question at the create new acc. page for members...which is succesfull..thx again for the contribution!!

 

my question is, how do i retrieve the values/answers entered by the customers at the admin page...

eg:catalog/admin/customers.php

what code should i put so that it can retrieve the values which is submitted by the customers?

 

a help on this would be very greatfull!!

Link to comment
Share on other sites

my question is, how do i retrieve the values/answers entered by the customers at the admin page...

eg:catalog/admin/customers.php

what code should i put so that it can retrieve the values which is submitted by the customers?

 

a help on this would be very greatfull!!

 

You can pretty much stick this line:

 

 <?php if (ASK_QUESTION == 'true')  require('display_answer_box.php'); ?>

 

in admin to display the answers. It was made for orders, invoice and packing slip but it might work for customers. I imagine this would be useful if you are asking questions in create account.

Shade and Sweet Water

Chris Czerniak

Link to comment
Share on other sites

i wanted to thank cczernia for writing and posting the documentation

also it seems that i forgotten two things these changes should resolve all outstanding issues

1-in checkout_confirmation.php i have not included the red line

 

 

//extra questions start

if (ASK_QUESTION == 'true') {

$display_answer = 1;

 

require('display_answer_after_order.php');

}

//extra questions end

 

 

 

2- please name this file

display_answer_box.php and place it in your admin folder and place the line that cczernia has mentioned in the post just before this

<?php
if (QUESTION_LOCATION == 'orders')$locID=(int)$oID;
if (QUESTION_LOCATION == 'account'){
$customer_id_query = tep_db_query("select  orders_id,customers_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");
$customer_id = tep_db_fetch_array($customer_id_query);
$locID=$customer_id['customers_id'];
}
if (QUESTION_LOCATION == 'after_purchase')$locID=(int)$oID;
$extra_questions_query = tep_db_query("select first_answer,second_answer,third_answer, fourth_answer,fifth_answer from " . TABLE_ANSWERS . " where location_id = '" . $locID . "'and location='" .QUESTION_LOCATION . "'" );
$extra_questions = tep_db_fetch_array($extra_questions_query);


 if (DISPLAY_FIRST_QUESTION == 'true') {
?>	 
		  <tr>

			<td class="main"><b><?php echo FIRST_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['first_answer']; 

?></td>
		  </tr>

<?php
}
 if (DISPLAY_SECOND_QUESTION == 'true') {
?>
		   <tr>
			<td class="main"><b><?php echo SECOND_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['second_answer']; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_THIRD_QUESTION == 'true')  {
?>
		   <tr>
			<td class="main"><b><?php  echo THIRD_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['third_answer']; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_FOURTH_QUESTION == 'true') {
?>
		  <tr>
			<td class="main"><b><?php echo FOURTH_TITLE; ?></b></td>
			<td class="main"><?php  echo $extra_questions['fourth_answer']; ?></td>
		  </tr>

<?php
 }
 if (DISPLAY_FIFTH_QUESTION == 'true')  {
?>
		  <tr>
			<td class="main"><b><?php  echo FIFTH_TITLE; ?></b></td>
			<td class="main"><?php echo $extra_questions['fifth_answer']; ?></td>
		  </tr>

<?php
}


?>

Edited by nana
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...