Page 1 of 9 123 ... LastLast
Results 1 to 10 of 84
  1. #1
    Join Date
    Aug 2006
    Posts
    100
    Plugin Contributions
    0

    Default Adding Field to Checkout

    I searched for this and only came up with one thread which was what I was looking for, but they figured out another way of doing it..

    I need to know if there is a way to add a field to the checkout. I send out frequent buyer cards to buyers, potential customers and for others to pass out too, so theres no way of me tracking WHO has a frequent buyer card so i want a frield in the check out just to ask if they have a frequent buyer card, so that if they dont, i can send them one. Is there anyway of doing this?

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

    Default Re: Adding Field to Checkout

    There are a couple of ways you can achieve this. Firstly, do you offer frequent buyer discount? If so, the best thing to do is to create a new order_total module, which checks the card validity, and if valid, gives a discount. But thats another topic, related, but different.

    Ok, so adding the fields to the checkout.

    BACKUP EVERYTHING BEFORE EDITTING ANY OF THESE FILES

    Firstly, you need to decide which page you are going to add the field to. If its the shipping page, then edit includes/templates/YOUR ACTIVE TEMPLATE/templates/tpl_checkout_shipping_default.php . If its the payment page, then edit tpl_checkout_payment_default.php in the same folder. Here you just need to add the field.

    The field needs to be as follows:
    <?php echo zen_draw_input_field('frequent_code'); ?>

    Next is the difficult bit.

    Firstly, you need to add a new column to the orders database table. Use phpmyadmin, and navigate to the table. Add a new column called order_frequent_code.

    Next, alter the order.php class file, found in includes/classes/order.php
    There are a fair number of bits to add, but bare with me:

    Line 43, add order_frequent_code, to the sql statement.

    Line 114, before 'ip_address' insert the following line:
    'frequent_code' => $order->fields['order_frequent_code'],

    Line 343, before 'ip_address' insert the following line:
    'frequent_code' => $_SESSION['frequent_code'],

    Line 587, before 'ip_address', insert the following line:
    'order_frequent_code' => $this->info['frequent_code'],

    Ok, nearly there. So far, we've added the field to the template, added the column to the database, and editted the order class to record the value. We now need to get the input and pass it to the order class.

    If you placed the new field in the shipping page, then you need to edit includes/modules/pages/checkout_shipping/header_php.php

    After line 116 add:
    if (isset($_SESSION['frequent_code'])) {
    $frequent_code = $_SESSION['frequent_code'];
    }
    After line 124, which starts $comments = $_SESS........ add

    if (zen_not_null($_POST['frequent_code'])) {
    $_SESSION['frequent_code'] = zen_db_prepare_input($_POST['frequent_code']);
    }
    $frequent_code = $_SESSION['frequent_code'];

    And that should be it!

    All you need to do now is work out how to display the extra information where you need it. If you want it on the orders page in the admin, then you will need to edit admin/orders.php as a starter.

    Good luck and hope it helps

    Absolute
    PS - I have used this before, but just to let you know its not a direct copy and paste, so I may have missed a ';' or two. If you have any issues, let me know

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

    Default Re: Adding Field to Checkout

    A very good, very comprehensive, very accurate and very clear response to one of those "more difficult than it looks" questions. Many thanks for posting it.

    I'd just add that since the order.php and the shipping header.php files are outside of the current over-ride system, it may be necessary to reapply the changes when you upgrade. I'd recommend checking the change documentation carefully to see if these files are included in the list of amended files.
    Kuroi Web Design and Development | Twitter

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

  4. #4
    Join Date
    Dec 2005
    Posts
    108
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    Absolute...this was great...unfortunately...it didn't work for me.

    Here's my situation-

    On this page:

    http://www.theemployeemall.com/chs/i...eckout_payment

    In the Values in Action certificates section, I need to add (under Certificate Number):

    Employee ID
    Reward Date
    Presenter

    Do you think you can modify your instructions for me...so I can get it to work?

    Thanks!

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

    Default Re: Adding Field to Checkout

    You are popping your fields onto the checkout payment page for which a small modification to the absolute's instructions would be needed.

    Unlike the checkout shipping page which recalls itself when it has finished to validate the input, the checkout payment page skips merrily onto the checkout confirmation page, so your validation and setting of $_SESSION variables needs to take place in the modules/pages/checkout_confirmation/header_php.php (just after line 51 would be appropriate). However, your checking whether they are already set (e.g. for when the user is returmned to the page after failing php-based validation) should be put in modules/pages/checkout_payment/header_php.php (after line 90 say).
    Kuroi Web Design and Development | Twitter

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

  6. #6
    Join Date
    Dec 2005
    Posts
    108
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    Thanks...I tried what you suggested and this is what I come up with:

    http://www.theemployeemall.com/chs/i...eckout_payment

    In the Values in Action Certificates section I get the three extra boxes I created (not aligned and with no identifier to say what info should go in there).

    But, I also get three additional text boxes in the Shopping Passes section. Those shouldn't be there.

    Any suggestions?

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

    Default Re: Adding Field to Checkout

    Can you post the code for the page you altered? Just the section you editted will be fine, for tpl_checkout_payment_default.php. THen we can take a look at your code, and iron out the issue.

    Absolute

  8. #8
    Join Date
    Dec 2005
    Posts
    108
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    The three field ID's I created are: employeeid, rewarddate, presenter.

    Here's the code:

    <fieldset>
    <legend><?php echo $selection[$i]['module']; ?></legend>
    <?php echo $selection[$i]['redeem_instructions']; ?>
    <div class="gvBal larger"><?php echo $selection[$i]['checkbox']; ?></div>
    <label class="inputLabel"<?php echo ($selection[$i]['fields'][$j]['tag']) ? ' for="'.$selection[$i]['fields'][$j]['tag'].'"': ''; ?>><?php echo $selection[$i]['fields'][$j]['title']; ?></label>
    <?php echo $selection[$i]['fields'][$j]['field']; ?>
    <?php echo zen_draw_input_field('employeeid'); ?>
    <?php echo zen_draw_input_field('rewarddate'); ?>
    <?php echo zen_draw_input_field('presenter'); ?>
    </fieldset>

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

    Default Re: Adding Field to Checkout

    Hey Steve,

    You'll notice that the previous line to the ones you posted is:

    <?php
    }
    for ($j=0, $n2=sizeof($selection[$i]['fields']); $j<$n2; $j++) {
    ?>

    This means that the code you have altered is within the FOR loop, which in your case, runs twice.

    I would recommend either including a check to ensure $j == 0, or move your code.

    If you want to include the test for $j==0, then use.....
    Code:
    if ($j==0) {
    YOUR NEW TEXTBOXES HERE
    }
    Good luck

    Absolute

  10. #10
    Join Date
    Dec 2005
    Posts
    108
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    Thanks...being that the boxes are where I need them, I can't move them (well, maybe I can, but that's probably a bigger issue than I need).

    So, it sounds like I have to do this "check," unfortunately I'm not exactly sure what I need to do.

    You provided code...is that the EXACT code I need to enter, and if so, where does it go?

 

 
Page 1 of 9 123 ... LastLast

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

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