Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2005
    Posts
    154
    Plugin Contributions
    0

    help question Setting Order Comments field required, and making it drop-down?

    Ok, so I want to have the customer choose who they found our website on the checkout procedure (on the first checkout page where they enter their shipping info) and require this to be completed.

    Now I didn't know how to do this so I thought, I'll just edit the Comments box and call it "How did you find us". This worked good, but people still weren't typing in how they found us so I want to make this field required.

    I also thought to change this to a drop-down with hard-coded choices for the user. I know I can edit the templates/tpl_checkout_shipping_default.php file and just draw out the drop-down and call it comments.

    So my questions are:

    1. How do I make the comments fields required? So that if there is nothing entered, the page will be displayed again and an error note saying they must select how they found us.

    2. This does away with the comment box, per se... any other ideas on how I can do this and still keep the comments box for comments?

    Thanks!

  2. #2
    Join Date
    Aug 2005
    Posts
    154
    Plugin Contributions
    0

    Default Re: Setting Order Comments field required, and making it drop-down

    Anyone have any ideas... I thought about this as well: What if I just added to the javascript to have it check that field and issue an error if it is "blank". What file (and where) do I have to edit to add to the javascript? It's not a perfect solution because sometimes javascript can be not installed or off in a client's computer but it's simpler I thought.

    Please help, I gotta get this going asap!

  3. #3
    Join Date
    Aug 2005
    Posts
    154
    Plugin Contributions
    0

    Idea or Suggestion Re: Setting Order Comments field required, and making it drop-down

    Didn't get any answers on this so I thought I would post my solution here for others who may need this in the future.

    So first I edited the checkout_shipping.php and checkout_payment.php template files and I changed the comments box from a textarea to a select box thus giving me a drop-down box with the appropriate choices. It's still called comments so everything works the same in the backend.

    Now, that solved me wanting a drop-down box but I still needed to make sure to validate that they chose an option from the drop-down. Here's how I solved that... I edited the file /includes/classes/payment.php and found the section of javascript that validates and added my validation code to it.

    The entire solution works great! Please let me know if anyone would like me to post the code I used, I'd be happy to.

  4. #4
    Join Date
    Mar 2007
    Location
    Seattle, WA
    Posts
    159
    Plugin Contributions
    0

    Default Re: Setting Order Comments field required, and making it drop-down

    Well done. . . I don't currently have a need for that functionality, however, it looks like you did a slended job.

  5. #5
    Join Date
    May 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: Setting Order Comments field required, and making it drop-down

    i would like to have the code please. maybe i can mod this for what i need.

  6. #6
    Join Date
    May 2008
    Posts
    9
    Plugin Contributions
    0

    Default Re: Setting Order Comments field required, and making it drop-down

    dave, i just emailed you through the zencart forum system. I would like some help adding a required script to the checkout process for 4 different fields that i have added.

    thanks,
    jamie

  7. #7
    Join Date
    Aug 2005
    Posts
    154
    Plugin Contributions
    0

    Default Re: Setting Order Comments field required, and making it drop-down

    I would like to see the code you used to change the comments from text to drop down. If you could email or post that would be appreciated.

    Thanks!
    KMF
    KMF,

    I don't have the code anymore (couldn't find it) but if you read my post above it's all laid out. Basically just change the text area to a dropdown. So that would be:

    Code:
    <textarea name="comments"></textarea>
    ... change to ...

    Code:
    <select name="comments">
       <option value="choice1">Choice 1</option>
       <option value="choice2">Choice 2</option>
       <option value="choice3">Choice 3</option>
    </select>
    And what that will do is just change the type of input field but the name is the same so it doesn't change anything about the way Zen processes it.

    The only other step was validation that something was selected, so as I stated in my last post in this thread "I edited the file /includes/classes/payment.php and found the section of javascript that validates and added my validation code to it".

    Hope that helps!

  8. #8
    Join Date
    Mar 2008
    Posts
    17
    Plugin Contributions
    0

    Default Re: Setting Order Comments field required, and making it drop-down

    Thanks, however I believe the comment box is generated by:

    Code:
    <fieldset class="shipping" id="comments">
    <legend><?php echo TABLE_HEADING_COMMENTS; ?></legend>
    <?php echo zen_draw_textarea_field('comments', '45', '3'); ?>
    </fieldset>
    in MYTEMPLATE/templates/tpl_checkout_shipping_default.php

    Also the <select> HTML code requires a <form> set but I don't believe that works with the PHP page here.

    It would make sense to use the zen_draw_pull_down function instead but I can't find any good source of how to code it properly.

    Any help would be appreciated. Thanks!

    KMF

  9. #9
    Join Date
    Aug 2005
    Posts
    154
    Plugin Contributions
    0

    Default Re: Setting Order Comments field required, and making it drop-down

    Basically I just hard-coded the drop down in that template file so I changed the default code to:

    Code:
    <fieldset class="shipping" id="comments">
    <legend><?php echo TABLE_HEADING_COMMENTS; ?></legend>
    <select name="comments">
      <option value="option1">Option 1</option>
      <option value="option2">Option 2</option>
      <option value="option3">Option 3</option>
    </select>
    </fieldset>
    And since that is using the same input name "comments" it will process properly. You don't have to mess with the zen_draw_pull_down function because it's overkill here.

 

 

Similar Threads

  1. Replies: 6
    Last Post: 24 Nov 2022, 08:51 PM
  2. v153 Can I make "comments" a "required field" when making a purchase?
    By pixel1987 in forum Setting Up Categories, Products, Attributes
    Replies: 12
    Last Post: 7 Jan 2015, 08:17 PM
  3. Need help making checkout comments required
    By igofresh in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 9 Feb 2011, 03:08 PM
  4. Make order comments a required field?
    By straitline in forum Basic Configuration
    Replies: 3
    Last Post: 29 Dec 2008, 02:05 AM
  5. Replies: 3
    Last Post: 31 Aug 2007, 07:29 AM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR