Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2012
    Posts
    4
    Plugin Contributions
    0

    Default Adding Field to Checkout

    how can I add a required field on the index.php?main_page=checkout_payment ( step 2 of 3 )

    this tutorial doesn't seem to work:

    http://www.zen-cart.com/forum/showthread.php?t=45080

    thank you for sharing the instructions (I'm kind of a newbie so step by step instructions would be greatly appreciated)

  2. #2
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Re: Adding Field to Checkout

    Just scroll down to the bottom of this page, there are several threads dealing with the same topic.

  3. #3
    Join Date
    Feb 2012
    Posts
    4
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    i can't find, can you please be more specific?
    all I can see below is :

    http://www.zen-cart.com/forum/showthread.php?t=36403
    http://www.zen-cart.com/forum/showthread.php?t=38256


    if you can be more specific and provide me an exact place where to get it working, I would really appreciate.

    thanks

  4. #4
    Join Date
    Feb 2012
    Posts
    4
    Plugin Contributions
    0

    Default Re: Adding Field to Checkout

    I followed the exact instructions and I made it appear on index.php?main_page=checkout_payment but it doesn't submit either to my email or to database?


    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!


    Where do I go wrong ? and also the last part must be added in ? includes/modules/pages/checkout_payment/header_php.php

    by last part I refer to :

    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 where does it exactly go this code? Line 124 doesn't even exist and I guess line 116 has modified also?
    I think that is the problem but I don't know how to solve it.
    Thanks.

 

 

Similar Threads

  1. Adding Field to Checkout
    By paperzombie in forum Templates, Stylesheets, Page Layout
    Replies: 83
    Last Post: 22 Jan 2016, 08:53 AM
  2. Adding select field to checkout
    By ETbyrne in forum Managing Customers and Orders
    Replies: 1
    Last Post: 22 Aug 2008, 02:34 AM
  3. adding a second Comments field to checkout?
    By Teacherk6 in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 24 Oct 2007, 04:30 PM
  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