Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Location
    Italy
    Posts
    155
    Plugin Contributions
    0

    Default How do I add an order field to the admin orders page?

    Hi,
    I'm trying to add a field to the order table and to show It in the admin order page.
    I added the field ORDER_FLAG to the database order table as TINYINT(1) (it should only have two values 1 and 0)
    The simpliest way i thought is to add some line to the /admin/orders.php

    For sure i need the heading:

    around line 845 after the <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td>

    I added:
    PHP Code:
    <td class="dataTableHeadingContent" align="center"><?php echo TABLE_ORDER_HEADING_FLAG?></td>
    I also added the define for the TABLE_ORDER_HEADING_FLAG

    Around line 969 after <td class="dataTableContent" align="right"><?php echo $orders->fields['orders_status_name']; ?></td>

    I would have something like this:

    PHP Code:
    <td class="dataTableContent" align="center"><?php echo ($orders->fields['ORDER_FLAG'] == 'x' ''); ?></td>
    The point is to show a "X" after the "Status" column on the admin order page for the orders that have the field ORDER_FLAG set to 1.

    The code part where the field is modified and populated is already done and working, my problem is only to shown it in the admin order page.

    The edit of /admin/order.php work but it shown nothing, for sure miss a call, any help would be appreciated

    Zencart ver 1.54
    PHP 5.3.3
    Mysql 5.1.73

  2. #2
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: How do I add an order field to the admin orders page?

    Couple things: typically (by convention) variables that are fully capitalized are constants. Does not mean that causes a problem here. Next convention (at least with ZC) is to populate fields with names that are all in lower case. ('order_flag' instead of 'ORDER_FLAG')

    The part that is more than likely the issue is retrieving the new field from the database to be used as desired. So whatever function is being called to assign data to $orders or a separate function/query yet to be written needs to retrieve your new field. This is primarily addressed in the includes/classes/order.php file. But you could do an independent query to obtain your data from the orders table(s).
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Mar 2009
    Location
    Italy
    Posts
    155
    Plugin Contributions
    0

    Default Re: How do I add an order field to the admin orders page?

    Quote Originally Posted by mc12345678 View Post
    Couple things: typically (by convention) variables that are fully capitalized are constants. Does not mean that causes a problem here. Next convention (at least with ZC) is to populate fields with names that are all in lower case. ('order_flag' instead of 'ORDER_FLAG')


    Thank You Mc, you are always kind .

    Sorry for the capitalized name, really it was only meant to point out the name of the variable and the field... in my database and in the file it is in lowercase.

    The part that is more than likely the issue is retrieving the new field from the database to be used as desired. So whatever function is being called to assign data to $orders or a separate function/query yet to be written needs to retrieve your new field. This is primarily addressed in the includes/classes/order.php file. But you could do an independent query to obtain your data from the orders table(s).
    Hmmm that's the point, just to be sure, is the includes/classes/order.php or is the admin/includes/classes/order.php the right file? Or both

    Thanks again

    (Strange i did't find any informations on something like this... there are a lot of informations on how to add and retrive field for customers or products but not for the orders... just a thought)

  4. #4
    Join Date
    Mar 2009
    Location
    Italy
    Posts
    155
    Plugin Contributions
    0

    Default Re: How do I add an order field to the admin orders page?

    I did IT!!

    First you need not to edit any ../class/order.php file, simply find the lines in /admin/orders.php:

    PHP Code:
    // eof: search orders or orders_products
    $new_fields ", o.customers_company, o.customers_email_address, o.customers_street_address, o.delivery_company, o.delivery_name, o.delivery_street_address, o.billing_company, o.billing_name, o.billing_street_address, o.payment_module_code, o.shipping_module_code, o.ip_address "
    and add the field you need to be searched at the end, for me it is:

    PHP Code:
    // eof: search orders or orders_products
        
    $new_fields ", o.customers_company, o.customers_email_address, o.customers_street_address, o.delivery_company, o.delivery_name, o.delivery_street_address, o.billing_company, o.billing_name, o.billing_street_address, o.payment_module_code, o.shipping_module_code, o.ip_address, o.ORDER_FLAG "


    p.s. I know i know.. the convention!!! sorry but i can't edit the previous post so i keep it uppercase to be consistent
    Last edited by izar74; 4 Jun 2015 at 07:06 PM.

  5. #5
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: How do I add an order field to the admin orders page?

    Quote Originally Posted by izar74 View Post
    Thank You Mc, you are always kind .

    Sorry for the capitalized name, really it was only meant to point out the name of the variable and the field... in my database and in the file it is in lowercase.



    Hmmm that's the point, just to be sure, is the includes/classes/order.php or is the admin/includes/classes/order.php the right file? Or both

    Thanks again

    (Strange i did't find any informations on something like this... there are a lot of informations on how to add and retrive field for customers or products but not for the orders... just a thought)
    Thought the second use might have been for emphasis, but wasn't sure. (At least others coming here now know.)

    Sorry about that, I've had the store side on my mind. Yes as you discovered, admin side of things for how you were trying to use your new lowercase (:) ) field.

    Glad you figured it out!
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. HOW TO Add a button on the Admin>Customer> Orders?
    By fe1lho in forum Managing Customers and Orders
    Replies: 0
    Last Post: 8 Jun 2010, 03:52 PM
  2. How to add form field to the shopper registration page?
    By erikcw in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 7 Oct 2009, 11:03 PM
  3. How do I add a purchase order field to the admin orders page?
    By kbascombe in forum Managing Customers and Orders
    Replies: 1
    Last Post: 1 Oct 2009, 02:48 AM
  4. Replies: 1
    Last Post: 9 Mar 2008, 09:28 PM
  5. Add Fax field in the Admin's Order page
    By MikeX in forum Customization from the Admin
    Replies: 4
    Last Post: 28 Nov 2006, 06:23 PM

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