Results 1 to 10 of 84

Hybrid View

  1. #1
    Join Date
    Nov 2008
    Posts
    18
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    Ive been wracking my brain for a few hours now on how to make a radio button group

    I found

    PHP Code:
    function zen_draw_radio_field($name$value ''$checked false$parameters '') {
        return 
    zen_draw_selection_field($name'radio'$value$checked$parameters);
      } 
    in includes/functions/html_output.php and I can get it to show a button on the page if i declair $name, $value, but i have no idea what $parameters should be.

    Obviously I have more than one set of options and values so im at a loss on how to get my options and values output onto the page.

    Any help or pointers to some example code is much apreciated

    Thanks in advance

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Adding Field to Checkout

    Quote Originally Posted by eddyboy View Post
    I found

    PHP Code:
    function zen_draw_radio_field($name$value ''$checked false$parameters '') {
        return 
    zen_draw_selection_field($name'radio'$value$checked$parameters);
      } 
    in includes/functions/html_output.php and I can get it to show a button on the page if i declair $name, $value, but i have no idea what $parameters should be.

    Obviously I have more than one set of options and values so im at a loss on how to get my options and values output onto the page.
    Parameters is a catch-all for anything else you need e.g. 'class="myRadioButton"'. You don't have to put anything in there if you don't need anything.

    You would use this function once of each option/value combination, grouping the options by giving them the same name, with each value for that option having its own unique value.

    You'll probably want to sprinkle lightly with LABEL tags too.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3
    Join Date
    Nov 2008
    Posts
    18
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    Quote Originally Posted by kuroi View Post
    Parameters is a catch-all for anything else you need e.g. 'class="myRadioButton"'. You don't have to put anything in there if you don't need anything.

    You would use this function once of each option/value combination, grouping the options by giving them the same name, with each value for that option having its own unique value.

    You'll probably want to sprinkle lightly with LABEL tags too.
    Wow, again.. thanks or the fast reply..

    Works great

  4. #4
    Join Date
    Nov 2008
    Posts
    18
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    That time to bug you for help again

    Ive tried and got no where with trying to make a feild required

    I am also struggling with a seperate javascript fix

    So once again, any help or pointers on making a feild required would be very much appreciated.


    Im sure a donation will be made, for the help in the forums and for the zencart system when my site is up and running
    I have made a fair few mods as well that I'd like to share with others, once the dust has settled.
    Last edited by eddyboy; 11 Feb 2009 at 05:33 PM. Reason: typos

  5. #5
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Adding Field to Checkout

    Ok, from the top!

    The way you add new fields has been shown earlier in this thread.

    To make them required, edit the header_php.php file you are currently working with - there should only be one. It's the one where you have $_SESSION['xxxx'] = $xxxx

    If there is a variable set somewhere in this page called $error, which is either true or false, you need to follow the same protocol.

    If not, then you can use this:

    Code:
      if (!zen_not_null($_POST['my_variable_name'])) {  //perform ALL checks on relevancy here
        $messageStack->add_session($_GET['main_page'], TEXT_ERROR_VARIABLE_MISSING, 'error');
        zen_redirect(zen_href_link($_GET['main_page']));
      }
    It's not the prettiest way of doing it, and if the customer has entered an entire page of data, and then comes across this type of error they will hate you, as none of their data will be re-populated, but as I don't know where you are adding the details, or what other modules you have installed, it is the only fail-safe way of doing it I can think of.

    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

  6. #6
    Join Date
    Nov 2008
    Posts
    18
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    Quote Originally Posted by Absolute View Post
    If not, then you can use this:

    Code:
      if (!zen_not_null($_POST['my_variable_name'])) {  //perform ALL checks on relevancy here
        $messageStack->add_session($_GET['main_page'], TEXT_ERROR_VARIABLE_MISSING, 'error');
        zen_redirect(zen_href_link($_GET['main_page']));
      }
    Absolute
    Thanks for the speedy reply.

    I have been editing the checkout_shipping/header_php.php page as i have put the new form on the index.php?main_page=checkout_shipping page. And I have gone through the code a few times but cant find any examples to copy.


    Anyway, I put in the new code so it reads like this
    PHP Code:
    if (zen_not_null($_POST['address'])) {
    $_SESSION['address'] = zen_db_prepare_input($_POST['address']);
    }
    $address $_SESSION['address'];

    if (!
    zen_not_null($_POST['address'])) {  //perform ALL checks on relevancy here
        
    $messageStack->add_session($_GET['main_page'], TEXT_ERROR_VARIABLE_MISSING'error');
        
    zen_redirect(zen_href_link($_GET['main_page']));
      } 
    but i get a redirect loop error-

    Redirect Loop
    Redirection limit for this URL exceeded. Unable to load the requested page
    .

    Im asuming this is because when the page first loads the variables have no value

    Again, thanks for your patiance and help.. I am coming to the end of what hasbeen a very long project, and my brain is starting to fail me All and any help is much appreciated

  7. #7
    Join Date
    Nov 2008
    Posts
    18
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    I think i have a work around.

    If I change a form feild to include some defult text

    PHP Code:
    <?php echo zen_draw_textarea_field('address''45''3','required feild'?>
    and tweak your last bit of code to

    PHP Code:
    if (($_POST['address'] =="required feild")) {  //perform ALL checks on relevancy here
        
    $messageStack->add_session($_GET['main_page'], TEXT_ERROR_VARIABLE_MISSING'error');
        
    zen_redirect(zen_href_link($_GET['main_page']));
      } 
    It means unless they change the text for something they enter it will throw an error.

    I think my brain has something left inside it after all

  8. #8
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Adding Field to Checkout

    Firstly, move that code so it comes BEFORE the if (zen_not_null($_POST['address'])) { line.

    And then change it so it reads:

    Code:
    if (isset($_POST['address']) && !zen_not_null($_POST['address'])) {  //perform ALL checks on relevancy here
        $messageStack->add_session($_GET['main_page'], TEXT_ERROR_VARIABLE_MISSING, 'error');
        zen_redirect(zen_href_link($_GET['main_page']));
      }
    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

  9. #9
    Join Date
    Jun 2009
    Location
    NC
    Posts
    174
    Plugin Contributions
    1

    Default Re: Adding Field to Checkout

    Anybody have any idea how I might add a checkbox that will enable users to split the shipment of their product should they desire to do so? I'd have to be able to see it in the orders area of the admin as well. I'm not particularly PHP savvy, in fact, I know just enough to get myself into trouble to be perfectly honest...all I've been able to get done so far is adding a split_shipment field in the orders database...

 

 

Similar Threads

  1. v151 Adding custom field during checkout
    By hues in forum General Questions
    Replies: 1
    Last Post: 9 Nov 2012, 10:39 PM
  2. Adding Field to Checkout
    By earlygrayte in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 17 Feb 2012, 03:00 PM
  3. Adding select field to checkout
    By ETbyrne in forum Managing Customers and Orders
    Replies: 1
    Last Post: 22 Aug 2008, 02:34 AM
  4. adding a field to checkout and db
    By StevenB in forum General Questions
    Replies: 0
    Last Post: 20 May 2007, 12:57 AM

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