PO Numbers on Invoices, Searchable in Orders.
I've been asked to include this modification for people who want to have order-based Purchase Order Numbers, pulling that info from the encrypted field and making it searchable in the admin Orders section. This mod also includes PO Numbers on invoices.
Caveat: In this mod, the new PO Number field is not encrypted. If that's important, then you must modify further to include encryption. This has been tested on X-Cart 4.1.7. You may wish to modify further for other versions of X-Cart. Don't forget -- Step One is to create a new field in the database. Steps Two through Ten follow in the next post. Step 1: Create a new database field with phpMyAdmin or another method in the xcart_orders table directly after "extra," called po_number. (Varchar(50), not null). see next post for more... :D |
Re: PO Numbers on Invoices, Searchable in Orders.
Step 2: Add this to the bottom of xcart_root_folder/include/func/func.db.php: --(See reply #6 for a fix.)
Code:
function getPONum($o_details) { Step 3: The above will not work if there are spaces in the PO Number, so modify xcart_root_folder/skin1/customer/main/payment_po.tpl: Add this script after the "required fields" script (just before the table tag): Code:
{literal} Code:
<input type="text" size="32" id="PO_Number" name="PO_Number" /> Code:
<input type="text" size="32" id="PO_Number" name="PO_Number" onChange="ckFld();" /> Step 4: Find the array in xcart_root_folder/include/func/func_order.php that begins: Code:
$insert_data = array ( Code:
'extra' => addslashes(serialize($_extra))); Code:
'extra' => addslashes(serialize($_extra)), Step 5: Modify xcart_root_folder/include/orders.php: Find the array: Code:
$advanced_options = array("orderid1", "orderid2", "total_max", "payment_method", "shipping_method", "status", "provider", "features", "product_substring", "productcode", "productid", "price_max", "customer", "address_type", "phone", "email"); Code:
$advanced_options = array("orderid1", "orderid2", "total_max", "payment_method", "po_number", "shipping_method", "status", "provider", "features", "product_substring", "productcode", "productid", "price_max", "customer", "address_type", "phone", "email"); In the same file, find: Code:
if (!empty($sort) && in_array($sort, array("orderid","status","customer","date","provider", "total"))) { Code:
if (!empty($sort) && in_array($sort, array("orderid","status","customer","date","po_number","provider", "total"))) { Then, find this "if" clause (around line 182): Code:
# Search by payment method Code:
# Search by po number The last mod on this file is to find this case (around line 420): Code:
case "date": Code:
case "po_number": // added for po number Step 6: In the file xcart_root_folder/admin/order.php, find this line (around line 190): Code:
$query_data['details'] = func_crypt_order_details($details); Code:
$query_data['po_number'] = getPOnum($details); Step 7: Edit the file xcart_root_folder/skin1/mail/html/order_invoice.tpl: Find this line: Code:
<b>{$lng.lbl_payment_method}:</b><br />{$order.payment_method}<br /><b>{$lng.lbl_delivery}:</b><br />{$order.shipping|trademark|default:$lng.txt_not_available} Code:
<b>{$lng.lbl_payment_method}:</b><br />{$order.payment_method}<br /><b>{$lng.lbl_po_number}:</b> {$order.po_number}<br /><b>{$lng.lbl_delivery}:</b><br />{$order.shipping|trademark|default:$lng.txt_not_available} Step 8: Edit the file xcart_root_folder/skin1/main/order_info.tpl: After the table row: Code:
<tr> Code:
<tr> Step 9: Edit the file xcart_root_folder/skin1/main/order_list.tpl: Find the section: Code:
<tr class="TableHead"> Code:
<tr class="TableHead"> Find this line: Code:
<td nowrap="nowrap"><a href="order.php?orderid={$orders[oid].orderid}">{$orders[oid].date|date_format:$config.Appearance.datetime_format}</a></td> Code:
<td nowrap="nowrap"><a href="order.php?orderid={$orders[oid].orderid}">{$orders[oid].po_number}</a></td> Step 10: Edit the file xcart_root_folder/skin1/main/orders.tpl: Find the line: Code:
var searchform_def = [ Code:
['posted_data[po_number]', ''] Now find the table row: Code:
<tr> Code:
<tr> That's it. :D |
Re: PO Numbers on Invoices, Searchable in Orders.
Hello ...
This is great :) It's working fine ... apart from just one thing .. I'm not sure if it's the function getPONum() but as well as attaching the PO Number is also grabbing the first word of the next line (In this case it's Company Name) So when i look at the database the po_number field is showing "5361 Company" (5361 is the actual po number i entered) Any ideas ? Thanks A Lot ... Regards Shafiq :sK |
Re: PO Numbers on Invoices, Searchable in Orders.
Oh, yes...
We removed the Company name and Name of purchaser from our po orders, so, no wonder this didn't come up! My function finds spaces, but not line returns. So here's a possible fix: Try this function instead in your file x-cart_root/include/func/func.db.php: Code:
function getPONum($o_details) { Let me know if that one works! :D |
Re: PO Numbers on Invoices, Searchable in Orders.
Hello ... Just tried this ... But no joy :(
Any other ideas ? Thanks & Regards Shafiq :sK |
Re: PO Numbers on Invoices, Searchable in Orders.
Ugh. :roll:
We've got to find how your system registers line breaks. So, try this function at the bottom of x-cart_root/include/func/func.db.php instead: Code:
function getPONum($o_details) { Does that do it? I hope so! :D |
Re: PO Numbers on Invoices, Searchable in Orders.
Excellent :D !!
That did the trick ... Thanks very much !!! Regards Shafiq :sK |
Re: PO Numbers on Invoices, Searchable in Orders.
Quote:
Hooray! :D Now it's a pretty nifty mod for 4.1.x. Cheers, |
Re: PO Numbers on Invoices, Searchable in Orders.
I tried this on 4.2 ... yikes ... all kinds of stuff is broken now ... I think i backed up all the files but one :( So now to try to undo it all...
|
Re: PO Numbers on Invoices, Searchable in Orders.
Quote:
Nevermind, I screwed up a step, it works fine! |
All times are GMT -8. The time now is 06:51 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.