Forums / Templates, Stylesheets, Page Layout / needing to add a P.O. number field to the checkout process

needing to add a P.O. number field to the checkout process

Locked

Started by graper on 7 Dec 2007, 2:56 PM · Views: 2,653

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
7 Dec 2007, 2:56 PM
#1
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

needing to add a P.O. number field to the checkout process

I'm needing to make a small addition to our template. I need to add a p.o. number field that can be used by customers to put in a p.o. number for accounting controls.

I know which tpl page to make changes to. I need to find the pages that accept the information and actually insert it into the database. Can anyone point to those files? and are they over-ridable?

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

10 Dec 2007, 8:46 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: needing to add a P.O. number field to the checkout process

Order information is written to the database via the order class file.
Once you've collected and validated the collected data (probably via the header_php file for that particular page), you'll need to then store the information into the order by adapting the order class to save that information with the order record. In the order class, it saves the data using a zen_db_perform() call to store the $sql_data_array contents.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Dec 2007, 9:02 PM
#3
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

I knew I was on the right path with the /includes/class/order.php but I didn't think to look at the /includes/modules/pages/* files.

If I made the field show up on the payment page, tpl_checkout_confirmation_default.php, which header would I need to work with, /includes/modules/pages/checkout_confirmation/header_php.php or would it /includes/modules/pages/checkout_payment/header_php.php?

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

10 Dec 2007, 9:30 PM
#4
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

Actually Placed the field in tpl_checkout_payment_default.php, I have it showing up on the checkout_confirmation page.

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

10 Dec 2007, 9:47 PM
#5
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

I got it to work, I put it in the header_php.php file for the checkout confirmation. thanks for the tip DrByte

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

8 Feb 2008, 8:44 PM
#6
0be1 avatar

0be1

Totally Zenned

Join Date:
Sep 2004
Location:
Murfreesboro, TN
Posts:
479
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

Can you please post the code that you inserted into header_php.php file so others can learn from your findings? I needed to do something similar and would like to see how this was resolved.

Thanks...

0be1

"Give me one hundred preachers who fear nothing but sin and desire nothing but God, and I care not whether they be clergymen or laymen, they alone will shake the gates of Hell and set up the kingdom of Heaven upon Earth." - John Wesley

11 Feb 2008, 4:42 PM
#7
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

0be1:

Can you please post the code that you inserted into header_php.php file so others can learn from your findings? I needed to do something similar and would like to see how this was resolved.

Thanks...

0be1

Sure No problem,

This method adds the P.O. Number field to the form so that it can be saved to the database in the order table, field name po_number If this P.O. Number is needed for a payment module for level 2 or 3 transaction, you'll need to modify the payment module to pull this information out.

in file /includes/modules/pages/checkout_confirmation/header_php.php
line 47, added

"//PO_number added by granville on 2007/12/10

if(isset($_POST['po_number'])) $_SESSION['po_number'] = zen_db_prepare_input($_POST['po_number']);"

to be able to save the p.o. number to the order in the database you have to do the following.
in file /includes/classes/order.php
line 54, added ",po_number"
line 123 added ",'po_number' => $order->fields['po_number']"
line 354 added ",'po_number' => (isset($_SESSION['po_number]) ? $_SESSION['po_number'] : '')"
line 615 added ",'po_number' => $_SESSION['po_number']"

the only thing I didn't do is to change the admin side to show the P.O. Number since I feel that the admin didn't need to know what the P.O. Number that the customer puts in. I imagine there could be a case where this would be needed, but I'm certain it's got to be easy to display it.

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

11 Feb 2008, 5:58 PM
#8
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

Granville... is it necessary to create a table in the dbase to store this PO data?

20 years a Zencart User

11 Feb 2008, 6:01 PM
#9
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

graper:

the only thing I didn't do is to change the admin side to show the P.O. Number since I feel that the admin didn't need to know what the P.O. Number that the customer puts in. I imagine there could be a case where this would be needed, but I'm certain it's got to be easy to display it.

I would imagine that the PO number is a very important part of the order record. I would like to use it, and mine would have to append to the order history in every respect. When a customer (or shop admin) calls up a transaction (order), it ought to be able to reconcile to a PO number, if the customer inserted such a number during checkout.

20 years a Zencart User

11 Feb 2008, 6:02 PM
#10
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

schoolboy:

Granville... is it necessary to create a table in the dbase to store this PO data?

No, just add the field name po_number to the existing order table. Here is some sql code to get it done.

ALTER TABLE `orders` ADD COLUMN `po_number` VARCHAR(15) AFTER `ip_address`;

should be able to run this from Tools > Install SQL patches.

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

11 Feb 2008, 6:09 PM
#11
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

schoolboy:

I would imagine that the PO number is a very important part of the order record. I would like to use it, and mine would have to append to the order history in every respect. When a customer (or shop admin) calls up a transaction (order), it ought to be able to reconcile to a PO number, if the customer inserted such a number during checkout.

hmmm.... It's a good thing the project that needed this hasn't been completed. I just realized that there a few other places where the P.O. Number needs to be displayed. The first of which is pulling it out to send to the customer via email.

As for the admin, I feel that it depends on the admin. For the project I'm on it wasn't important to have the Cutomer's P.O. number viewable only because we discussed it and it was decided that if a customer needed to get some support on an order they the order number from zen would have to be used, only because there is the possibility that more then one customer may use the same p.o. number, rare but with that chance it's better to not use the customers p.o. as a tracking method. at which point why does the admin need to see it. Regardless it's just a matter of opinion and it should be super simple to display it on the full order page, not sure how hard to insert it into the list or orders though.

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

11 Feb 2008, 6:20 PM
#12
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

I have clients who manually take order data out of zencart to input into their bespoke accountancy systems (yep.. I know... dumb to replicate the task of data input - should build a query to do this!) but right now clients have budget constraints!

maybe Doc Byte can tell us all the instances where order information is called up and parsed into a page or email message - particularly as you say, in the e-mail order confirmation, order history, etc...:yes:

20 years a Zencart User

11 Feb 2008, 8:32 PM
#13
graper avatar

graper

New Zenner

Join Date:
Jul 2006
Posts:
50
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

Ok guys,

I figured I would post everything again to have it in one post. This should be everything EXCEPT the ability to edit the P.O. Number by either side. Can't have it all. These changes will place the P.O. Number field into the checkout process and will show the P.O. Number on "My Account" order list, "My Account" single order view, admin orders list, admin invoice, admin packing slip, and admin edit pages.

Zen-Cart CORE files that needs to be edited. This will make upgrading a lot harder in the future.

/admin/includes/classes/order.php
/admin/orders.php
/admin/invoice.php
/admin/packingslip.php

/includes/classes/order.php
/includes/modules/pages/account_history_info/header_php.php
/includes/modules/pages/checkout_confirmation/header_php.php

customize the following pages for you individual templates, copy them out of the default template.

tpl_account_default.php
tpl__account_history_info_default.php

let's start editing.

Admin changes
/admin/includes/classes/order.php
line 37 added ", po_number" to the query
line 78 added ", 'po_number=>$order->fields['po_number']"

/admin/orders.php
line 402 added "     P.O. Number: <strong><?php echo $order->info['po_number']; ?></strong>" before the "</td>"
line 674 added "<td class="dataTableHeadingContent" align="center">P.O. Number</td>" a whole new table cell.
line 718 added ", o.po_number" to the query
line 730 added ", o.po_number" to the query
line 742 added ", o.po_number" to the query
line 798 added "<td class="dataTableContent" align="left"><?php echo $orders->fields['po_number'];?> </td>" a whole new table cell.

/admin/invoice.php
line 143 added "     P.O.Number: <strong><?php echo $order->info['po_number']; ?></strong>" before the "</td>"

/admin/packingslip.php[/B]
line 137 added "     P.O.Number: <strong><?php echo $order->info['po_number']; ?></strong>" before the "</td>"

Customer side changes
/includes/classes/order.php
line 54, added ",po_number"
line 123 added ",'po_number' => $order->fields['po_number']"
line 353 added ",'po_number' => (isset($_SESSION['po_number]) ? $_SESSION['po_number'] : '')"
line 615 added ",'po_number' => $_SESSION['po_number']"

/includes/modules/pages/account_history_info/header.php
line 37 added ",o.po_order"
line 66 added ",'po_number'=>$orders->fields['po_number']"

/includes/modules/pages/checkout_confirmation/header_php.php
line 47, added "if(isset($_POST['po_number'])) $_SESSION['po_number'] = zen_db_prepare_input($_POST['po_number']);"

template changes
tpl_account_history_info_default.php
line 95-97 add a whole new table cell between status date and order status "<th scope="col" id="myAccountStatusPONumber">P.O. Number</th>"
line 104-105 add another table cell between date_added and status name "<td><?php echo $order->info['po_number'];?></td>"

tpl_account_default.php
line 30-32 add a whol new table cell between order_number and shipped to "<th scope="col">P.O. Number</th>"
line 43-45 add another line betwwn orders_id and order address "<td width=""><?php echo $orders['po_number']; ?></td>"

hope this takes care of it.
Have fun

Granville [granville (at) kirkhamsystems.com]
Kirkham Systems, Inc.

18 Feb 2008, 11:22 AM
#14
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: needing to add a P.O. number field to the checkout process

Thanks! ... I'll give this a go on a test shop. Advice to everyone who uses this. MAKE GOOD NOTES of the mods to core code... Will be helpful for future upgrades.

20 years a Zencart User