Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

beta release extra questions


nana

Recommended Posts

Sorry everbody if this ends up in the wrong place but I'm new to using forums!!!

 

I've installed Extra questions and all went well........or so I thought! When I go into admin to edit questions I click on BOX_HEADING_QUESTIONS in the left column and it can't find the page?

Please somebody point me in the right direction as I'm no PHP guru, but a hard tryer.

 

Regards

 

Hylton

Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 84
  • Created
  • Last Reply

Top Posters In This Topic

Hello,

 

I only want to add the 5 questions in the "checkout_success.php" page. Do I still have to modify all 15 files (per your instructions)? Can it work only modifying:

 

*checkout_success.php

*includes/database_tables.php

*includes/functions/html_output.php

*includes/languages/english.php

*admin/includes/filenames.php

*admin/includes/column_left.php.php

*admin/includes/database_tables.php

*admin/includes/languages/english.php

 

Thanks,

Jess.

 

P.S. I think this contribution is EXACTLY what I was looking for - thanks it seems great! :-)

 

 

Hello ! This is exactly what I am looking for too - but I only want to have one question on the checkout page.

 

Did you ever figure out how to do this ?

 

thanks

 

Donna

Link to comment
Share on other sites

I am currently installing "extra questions 1.5" in my shop and I came across a few things I had to change to make things work. I'm still testing and my shop is heavily modified, so please be careful!

 

INSTALLATION GUIDE

 

New files for catalog

I uploaded the file "questions_english.php" into includes/languages/english

I also uploaded the file "email_box.php" into includes/languages/english

I did not find a file called "extra_questions.php"

 

New files for admin

I found the file "display_answer_box" inf version 1.1 and uploaded to /admin

I uploaded the file "questions_english.php" to /admin/includes/languages/english

 

In checkout_shipping.php the code which mentions "TABLE_HEADING_COMMENTS" is around line 400, not around line 12 as stated

 

In both english.phpfiles (admin & catalog) I changed the code to:

require (DIR_WAS_LANGUAGE . $language . '/' . 'questions_english.php');

 

in admin/invoice.php, packing_slip.php and orders.php if you want to install the code in the HTML part do not use the "//" but use this code instead (forward slash comments are for PHP).

<!-- extra questions start -->
<?php if (ASK_QUESTION == 'true')  require('display_answer_box.php'); ?> 
<!-- extra questions end -->

 

OTHER AMENDMENTS

 

I installed the code on checkout_payment.php (as my shop does not use the shipping page). I then had the problem that the answers did not show correctly on checkout_confirmation.php. To make this work I have amended display_answer_after_order.php as follows:

WARNING - this is for shops which display the queries at "orders"! for other settings you'll need to tweak it.

 

find this code (around line 13)

}
$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'];
}

and replace with this code:

}
$first_answer=$HTTP_POST_VARS['question_one_form'];
$second_answer=$HTTP_POST_VARS['question_two_form'];
$third_answer=$HTTP_POST_VARS['question_three_form'];
$fourth_answer=$HTTP_POST_VARS['question_four_form'];
$fifth_answer=$HTTP_POST_VARS['question_five_form'];
}

 

My second question is a checkbox. If a customer chooses "no", i.e. the box is unticked, then on the confirmation page I wanted to display a "No" rather than an empty field. To achieve this I found this code in "display_answer_after_code.php" around line 36:

<td class="main"><?php echo $second_answer; ?></td>

 

and replaced it with this code:

<td class="main"><?php if ($second_answer == true) {echo $second_answer;}				 					else {echo 'No';}  ?></td>

not an elegant solution - will try to solve this better, but for now it does the job.

 

A first test seems to show that fields are included in the email and show in the admin. I have not yet tested the security of this contribution and am currently only testing on a localhost server on my PC.

 

Overall a great contribution which should be of use to lots of shops - a BIG THANK YOU to the author!

 

Terra (not just a happy bunny because of Easter) :thumbsup:

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

I am posting my modifications in case somebody else is trying to do the same thing - but all work in progress, so tread carefully!

 

I wanted to

a) display the questions on the checkout_confirmation page - but only if the question had been answered, and I wanted an "edit" button like the comments box next to it (which brings you back to checkout_payment)

b) make the checkout to remember what answers you had entered

c) solve a problem I had with the answers not appearing in checkout_confirmation

 

To solve the above I did the following:

 

1. On checkout_confirmation and checkout_payment, I entered this code in the top (PHP) part:

// extra questions start
if (!tep_session_is_registered('question_one_form')) tep_session_register('question_one_form');
if (tep_not_null($HTTP_POST_VARS['question_one_form'])) {
$question_one_form = ($HTTP_POST_VARS['question_one_form']);
}  
if (!tep_session_is_registered('question_two_form')) tep_session_register('question_two_form');
if (tep_not_null($HTTP_POST_VARS['question_two_form'])) {
$question_two_form = ($HTTP_POST_VARS['question_two_form']);
}  
if (!tep_session_is_registered('question_three_form')) tep_session_register('question_three_form');
if (tep_not_null($HTTP_POST_VARS['question_three_form'])) {
$question_three_form = ($HTTP_POST_VARS['question_three_form']);
}  
if (!tep_session_is_registered('question_four_form')) tep_session_register('question_four_form');
if (tep_not_null($HTTP_POST_VARS['question_four_form'])) {
$question_four_form = ($HTTP_POST_VARS['question_four_form']);
}  
if (!tep_session_is_registered('question_five_form')) tep_session_register('question_five_form');
if (tep_not_null($HTTP_POST_VARS['question_five_form'])) {
$question_five_form = ($HTTP_POST_VARS['question_five_form']);
}	  
 // extra questions end

 

2. On checkout_confirmation I replaced the code snipped suggested by the installation guide with this:

//extra questions start
if (QUESTION_LOCATION == 'orders') {
	if ((tep_not_null($HTTP_POST_VARS['question_one_form'])) | (tep_not_null($HTTP_POST_VARS['question_two_form'])) | (tep_not_null($HTTP_POST_VARS['question_three_form'])) | (tep_not_null($HTTP_POST_VARS['question_four_form'])) | (tep_not_null($HTTP_POST_VARS['question_five_form']))) {
	?>
<h2><?php echo HEADING_EXTRA_QUESTIONS . '<a class="edit" href="' . tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL') . '">(' . TEXT_EDIT . ')</a>'; ?></h2>	
<?php 	
	$display_answer = 'confirmation_page';
	require('display_answer_after_order.php');
}
} 
//extra questions end

 

3. In display_answer_after_order.php I replaced the entire file with this code:

<?php
if ($display_answer == 'confirmation_page' ) {
$first_answer=$HTTP_POST_VARS['question_one_form'];
$second_answer=$HTTP_POST_VARS['question_two_form'];
$third_answer=$HTTP_POST_VARS['question_three_form'];
$fourth_answer=$HTTP_POST_VARS['question_four_form'];
$fifth_answer=$HTTP_POST_VARS['question_five_form'];
}else{
if (QUESTION_LOCATION == 'orders')
{$locID=$HTTP_GET_VARS['order_id'];
}else{
$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'];
}
?>
<table>

<?php
 if ((DISPLAY_FIRST_QUESTION == 'true') && (tep_not_null($first_answer)))  {
?>	 
		  <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') && (tep_not_null($second_answer))) {
?>
		   <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') && (tep_not_null($third_answer))) {
?>
		   <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') && (tep_not_null($fourth_answer))) {
?>
		  <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') && (tep_not_null($fifth_answer))) {
?>
		  <tr>
			<td class="main"><b><?php  echo FIFTH_TITLE; ?></b></td>
			<td class="main"><?php echo $fifth_answer; ?></td>
		  </tr>

<?php
}

?>
</table>

All of the above has been done for a shop with displays the questions only on the checkout_payment page. Please note that amendments 2 & 3 are related (amendment 2 sets "$display_answer = 'confirmation_page';" which is then needed for the logic in amendment 3).

 

Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

Contribution is now fully installed & working great!

 

Here's the code for another modification I made - basically, I wanted a better looking email. Plus, if a customer came back to the site to place another order, I wanted the answer variables to be empty again. And I only wanted to show questions in the email for which answers were supplied.

 

ROOT LEVEL

 

In checkout_payment.php at the top my code looks like this:

 

//extra questions start
if (!tep_session_is_registered('question_one_form')) tep_session_register('question_one_form');
if (tep_not_null($HTTP_POST_VARS['question_one_form'])) {
$question_one_form = ($HTTP_POST_VARS['question_one_form']);
}	
if (!tep_session_is_registered('question_two_form')) tep_session_register('question_two_form');
if (tep_not_null($HTTP_POST_VARS['question_two_form'])) {
$question_two_form = ($HTTP_POST_VARS['question_two_form']);
}  
if (!tep_session_is_registered('question_three_form')) tep_session_register('question_three_form');
if (tep_not_null($HTTP_POST_VARS['question_three_form'])) {
$question_three_form = ($HTTP_POST_VARS['question_three_form']);
}  
if (!tep_session_is_registered('question_four_form')) tep_session_register('question_four_form');
if (tep_not_null($HTTP_POST_VARS['question_four_form'])) {
$question_four_form = ($HTTP_POST_VARS['question_four_form']);
}  
if (!tep_session_is_registered('question_five_form')) tep_session_register('question_five_form');
if (tep_not_null($HTTP_POST_VARS['question_five_form'])) {
$question_five_form = ($HTTP_POST_VARS['question_five_form']);
}	  

if (QUESTION_LOCATION == 'orders')  require('extra_questions_upload_result_box.php');	
 // extra questions end

 

 

In checkout_confirmation.php at the top my code looks like this:

 

  // extra questions start
if (!tep_session_is_registered('question_one_form')) tep_session_register('question_one_form');
if (tep_not_null($HTTP_POST_VARS['question_one_form'])) {
$question_one_form = ($HTTP_POST_VARS['question_one_form']);
} else { $question_one_form = ''; }

if (!tep_session_is_registered('question_two_form')) tep_session_register('question_two_form');
if (tep_not_null($HTTP_POST_VARS['question_two_form'])) {
$question_two_form = ($HTTP_POST_VARS['question_two_form']);
}  else { $question_two_form = ''; }

if (!tep_session_is_registered('question_three_form')) tep_session_register('question_three_form');
if (tep_not_null($HTTP_POST_VARS['question_three_form'])) {
$question_three_form = ($HTTP_POST_VARS['question_three_form']);
}  else { $question_three_form = ''; }

if (!tep_session_is_registered('question_four_form')) tep_session_register('question_four_form');
if (tep_not_null($HTTP_POST_VARS['question_four_form'])) {
$question_four_form = ($HTTP_POST_VARS['question_four_form']);
}  else { $question_four_form = ''; }

if (!tep_session_is_registered('question_five_form')) tep_session_register('question_five_form');
if (tep_not_null($HTTP_POST_VARS['question_five_form'])) {
$question_five_form = ($HTTP_POST_VARS['question_five_form']);
}else { $question_five_form = ''; }
 // extra questions end

 

 

In checkout_process.php before "if ($order->info['comments']) {" I have inserted:

 

//extra questions start
if (QUESTION_LOCATION == 'orders'){$locID= $insert_id;
}else{
$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 = '" . $locID . "'and location='" .QUESTION_LOCATION . "'" );
$extra_questions = tep_db_fetch_array($extra_questions_query);

if ((tep_not_null($first_answer)) | (tep_not_null(second_answer)) | (tep_not_null(third_answer)) | (tep_not_null($fourth_answer)) | (tep_not_null($fifth_answer))) {
	$email_order .= EMAIL_TEXT_QUESTIONS . "\n" . 
			  EMAIL_SEPARATOR . "\n"; 
}

if ((DISPLAY_FIRST_QUESTION == 'true') && (tep_not_null($first_answer)))  {
	$email_order .= EMAIL_TEXT_FIRST . ' www.' . $extra_questions['first_answer'] . "\n";
}
if ((DISPLAY_SECOND_QUESTION == 'true') && (tep_not_null($second_answer))) {
	$email_order .= EMAIL_TEXT_SECOND . ' ' . $extra_questions['second_answer'] . "\n";
 }
  if ((DISPLAY_THIRD_QUESTION == 'true') && (tep_not_null($third_answer))) {
	$email_order .= EMAIL_TEXT_THIRD . ' ' . $extra_questions['third_answer'] . "\n";
 }
 if ((DISPLAY_FOURTH_QUESTION == 'true') && (tep_not_null($fourth_answer))) {
	$email_order .=  EMAIL_TEXT_FOURTH . ' ' . $extra_questions['fourth_answer'] . "\n";
  }
  if ((DISPLAY_FIFTH_QUESTION == 'true') && (tep_not_null($fifth_answer))) {
	$email_order .= EMAIL_TEXT_FIFTH . ' ' . $extra_questions['fifth_answer'] . "\n";
 }
	$email_order .= "\n";	
//extra questions end

 

 

In checkout_process.php after " tep_session_unregister('comments');" I have inserted:

 

  tep_session_unregister('question_one_form');
 tep_session_unregister('question_two_form'); 
 tep_session_unregister('question_three_form');
 tep_session_unregister('question_four_form');  
 tep_session_unregister('question_five_form');

 

LANGUAGE LEVEL (/ENGLISH/)

 

In checkout_process.php I have inserted this code:

 

define('EMAIL_TEXT_QUESTIONS', 'Extra Questions:');
define('EMAIL_TEXT_FIRST', 'First Question': ');
define('EMAIL_TEXT_SECOND', 'Second Question: ');
define('EMAIL_TEXT_THIRD', 'Third Question: ');
define('EMAIL_TEXT_FOURTH', 'Fourth Question');
define('EMAIL_TEXT_FIFTH', 'Fifth Question');

 

 

The code is geared towards shops displaying questions on the checkout_payment.php. With the above code you won't need "email_box.php".

 

If you have a drop-down and have a problem with a number appearing as answer (e.g. 2), then add this code to the above logic: && ($second_answer != '2') as e.g. in:

if ((DISPLAY_SECOND_QUESTION == 'true') && (tep_not_null($second_answer)) && ($second_answer != '2')) {

and it won't show.

 

Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

Terra - Thank you for posting your enhancements ... they are great!

 

Frank - Thank you for the warning !!! Please let us know when you confirm how your site was hacked.

 

Regards,

EricK

Link to comment
Share on other sites

please do not use this contribution as it might have been the way that one of my sites have been hacked

i have already informed a moderator to remove it

Yes, I have it on my list to check the fields for security as I did notice that your form fields are not sanitised (and all input fields are to be treated with great care)! But I have written sanitisation checks before, so will get going on this. Or maybe try to figure out how osCom does it & then just use the existing checks.

 

One query though - you did make your admin panel available, which to me is a really dangerous thing as it gives access to the site and server .... does your hacked site have any connection with the admin panel you posted? I'd ask a moderator to remove the link in any case - way too dangerous! ;)

 

All the best for restoring your site! Edith

 

PS: another thought - you included your code files (e.g. "extra_question_db_upload_box.php") at root level - I have changed this to the /includes/ folder as it is best practice to place code in sub-folders which cannot be directly accessed (if anybody tries, they just get a Permission denied error if access is set up correctly). I'd advise to put all code which is to be included in another file into a subfolder & protect it (which osCom does)!

Edited by Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

Seems a shame to give up on this mode, so I'm battling on.

 

Please note that above code I posted is currently NOT working with PayPal IPN. :huh:

 

And the tep_session_unregister code also must be added to log_off.php so that info is removed when customer logs on (otherwise people sharing a PC will get each others answers).

 

Terra

My code for combining PayPal IPN with ** QTPro 4.25 ** osC Affiliate ** CCGV(trad)

and how to solve the invoice already paid error

General info: Allow customer to delete order comment ** FTP Programs & Text Editors ** Amending order email **

Link to comment
Share on other sites

  • 2 months later...

Frank and Terra

 

This is a great contribution and as it is essential for my site I will continue to try and develop using it (accepting the risks! :( )

 

Has anyone included this within their site and managed to integrate it with Paypal IPN?

 

As I am a php beginner/intermediate coder any clues would be appreciated

 

Phil

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...