Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to make users check a T&Cs checkbox on a/c creation


Leighbee

Recommended Posts

Posted

Right, I've managed to get as far as adding a "Terms and Conditions" checkbox to the account creation page:

 

screenshot.jpg

 

 

and I've added some define fields to english.php:

 

define('ENTRY_TERMS', 'I have read, and agree to, the <a href="http://www.kidstuff.org.uk/shop/conditions.php?" target="_blank">Terms & Conditions</a>:');

define('ENTRY_TERMS_TEXT', '');

define('ENTRY_TERMS_ERROR', 'You must confirm that you have read, and agree to, the terms and conditions before you continue.');

 

Now I'm stuck.

 

How can I get the system to throw up an error if they don't check the "I've read and agree to the terms and conditions" checkbox?

cmd-z... the best keystroke invented

Posted

There's at least one contribution for this...it is called something like "customer must accept terms and conditions".

 

Of course nobody really reads the terms & conditions page :)

Posted
How can I get the system to throw up an error if they don't check the "I've read and agree to the terms and conditions" checkbox?

 

Put simply, you must define a POST variable for the checkbox, then process that POST variable in the same block of code that processes all the others.

 

This processing takes place in create_account.php, after this line:

 

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

 

In PHP, a checkbox that is checked will create a POST variable with the specified name as the key, and the specified value as the value. A checkbox that isn't checked will not return a POST variable at all. So to determine if the box was checked, all you need to do is check for the existence of the POST variable. Here's some sample code:

 

if (!isset($HTTP_POST_VARS['name'])) {
 $error = true;
 $messageStack->add('create_account', ENTRY_TERMS_ERROR);
}

where "name" is the name of the checkbox that you defined in the call to tep_draw_checkbox_field().

Check out Chad's News.

Posted

Thanks everyone for your replies!

 

DunWeb and Hotclutch, I had spent ages searching the forums for a solution, but just couldn't find my way through the thousands of potential answers, so I'm sorry I missed the contribution - I'm still finding my way around here. Thanks for that. I was just in the process of installing it when chadcloman's solution arrived, and that has worked perfectly.

 

Chadcloman - you're a star. Just what I wanted! I'd fiddled about with copying and altering other fields, but I know too little about it to know why it didn't work. It works now!! Thank you!!

cmd-z... the best keystroke invented

Archived

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

×
×
  • Create New...