osCmax v2.5 User Manual
Results 1 to 3 of 3

Help Making Comments Box Required field

This is a discussion on Help Making Comments Box Required field within the osCMax v2 Features Discussion forums, part of the osCmax v2.0 Forums category; Need a required field for delivery date I've searched the forums, Googled the question, searched contributions and read a couple ...

      
  1. #1
    New Member
    Join Date
    Dec 2005
    Posts
    6
    Rep Power
    0


    Default Help Making Comments Box Required field

    Need a required field for delivery date

    I've searched the forums, Googled the question, searched contributions and read a couple of posts that didn't answer the question.

    Can someone please tell me how to make the comments box a required field from the checkout_shipping.php page?

    I would like to have people input an approximate delivery date that they want to have their order shipped. Can I make the comments box a manditory field or would it be better to add another text field and make it manditory? We ship fruit from FL and need this as a function from the checkout procedure. Please help US!

    Thank You!

  2. #2
    Member
    Join Date
    Jan 2004
    Location
    edmonton, Alberta, Canada
    Posts
    62
    Rep Power
    0


    Default Re: Help Making Comments Box Required field

    You don't have to add another text field. Mainly if you need the field to be manditory, it's better to use the one you've got. Making a new field for important info will require making a new field in the database. I would stick to making the comments field manditory and maybe renaming it... or inserting some text intsucting the customer to write in the box. And on top of that make it so they have to write something in the box. I have not looked at the code in quite sometime I've been out of the loop for a bit. I am certain I can help you though if you would give me sometime.

  3. #3
    Member
    Join Date
    Jan 2004
    Location
    edmonton, Alberta, Canada
    Posts
    62
    Rep Power
    0


    Default Re: Help Making Comments Box Required field

    make a back up copy of catalog/checkout_shipping.php and catalog/includes/languages/english.php.
    Goto catalog/includes/languages/english.php and find the following line...

    define('ENTRY_COMPANY', 'Company Name:');

    above it add the following ....

    define('ENTRY_COMMENTS_ERROR', 'delete this text and type what you want the error to say');

    now goto your catalog/checkout_shipping.php find the following code

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

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

    if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
    if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) {
    $shipping = $HTTP_POST_VARS['shipping'];

    list($module, $method) = explode('_', $shipping);
    if ( is_object($$module) || ($shipping == 'free_free') ) {
    if ($shipping == 'free_free') {
    $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
    $quote[0]['methods'][0]['cost'] = '0';
    } else {
    $quote = $shipping_modules->quote($method, $module);
    }
    if (isset($quote['error'])) {
    tep_session_unregister('shipping');
    } else {
    if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
    $shipping = array('id' => $shipping,
    'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
    'cost' => $quote[0]['methods'][0]['cost']);

    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYME NT, '', 'SSL'));
    }
    }
    } else {
    tep_session_unregister('shipping');
    }
    }
    } else {
    $shipping = false;

    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYME NT, '', 'SSL'));
    }
    }

    change it to this

    //Added for required comments field
    $error = false;
    // 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');
    $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
    if (strlen($comments) < 5) {
    $error = true;

    $messageStack->add('comments', ENTRY_COMMENTS_ERROR);
    }

    if ( $error == false) {
    if (!tep_session_is_registered('shipping')) tep_session_register('shipping');

    if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
    if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) {
    $shipping = $HTTP_POST_VARS['shipping'];

    list($module, $method) = explode('_', $shipping);
    if ( is_object($$module) || ($shipping == 'free_free') ) {
    if ($shipping == 'free_free') {
    $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
    $quote[0]['methods'][0]['cost'] = '0';
    } else {
    $quote = $shipping_modules->quote($method, $module);
    }
    if (isset($quote['error'])) {
    tep_session_unregister('shipping');
    } else {
    if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
    $shipping = array('id' => $shipping,
    'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
    'cost' => $quote[0]['methods'][0]['cost']);

    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYME NT, '', 'SSL'));
    }
    }
    } else {
    tep_session_unregister('shipping');
    }
    }
    }
    } else {
    $shipping = false;

    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYME NT, '', 'SSL'));
    }
    }

    I think it may work. If not just replce files with the backup copies.

Similar Threads

  1. Add required to some of the field names
    By oneplace2u in forum osCommerce 2.2 Modification Help
    Replies: 0
    Last Post: 09-04-2006, 05:33 PM
  2. comments box
    By joanstead in forum osCmax v2 Installation issues
    Replies: 0
    Last Post: 03-25-2006, 05:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •