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! |
Re: PO Numbers on Invoices, Searchable in Orders.
Quote:
WHEW! :-) |
Re: PO Numbers on Invoices, Searchable in Orders.
Quote:
Hi....... about to try this on 4.2..... should the routine in #6 be used on this version? All the best |
Re: PO Numbers on Invoices, Searchable in Orders.
Quote:
Most likely it should. This code works on 4.17; if 4.2 doesn't use the variable $query_data on order.php, you may have to modify yours to find out the right array to add the po number to. (We had no luck migrating the whole store to 4.2, so we're sticking to 4.17 for now.) |
Re: PO Numbers on Invoices, Searchable in Orders.
Hi Russell
can confirm that this does work on 4.2.2 with the routine from #6 best regards Adrian |
Re: PO Numbers on Invoices, Searchable in Orders.
Works great. Except a small problem. PO Number field appears on every invoice whether the payment method is Purchase order or any other. Need to show the field on invoice, only if payment method is Purchase Order.
|
Re: PO Numbers on Invoices, Searchable in Orders.
customer/main/order_message.tpl
Code:
{if $order.order.payment_method eq "Purchase Order"}{$order.order.po_number}{/if} mail/html/order_invoice.tpl (used in Print Invoice on Admin) Code:
{if $order.payment_method eq "Purchase Order"}{$order.po_number}{/if} That should give you a general idea of what to do. |
Re: PO Numbers on Invoices, Searchable in Orders.
Thanks.
I changed mail/html/order_invoice.tpl , Code:
<b>{$lng.lbl_po_number}:</b> {$order.po_number}<br /> Code:
{if $order.payment_method eq "Purchase Order"} But this does not display PO Number field even if the payment method is Purchase Order. I don't know what is wrong. |
Re: PO Numbers on Invoices, Searchable in Orders.
Never Mind, It is working now. Thanks for your help.
|
Re: PO Numbers on Invoices, Searchable in Orders.
anytime
|
Re: PO Numbers on Invoices, Searchable in Orders.
Quote:
Hues, did you have to do anything special to get the po_number field to appear? I don't see the variable anywhere in the debug console on the invoice page, and when I view the order, the PO number, company, etc. are all in just big text blob. I've tried variations on {$order.po_number}, without success. Is there some setting to allow this to function as you'd expect? 4.3.2 doesn't seem to like it. |
Re: PO Numbers on Invoices, Searchable in Orders.
I just added this hack to order_invoice.tpl. It displays the PO number by using regex in the smarty template to remove everything after the first line break in $order.details.
{if $order.payment_method eq "Purchase Order"}{$order.details|regex_replace:"/[\n].*/":""}{/if} |
Re: PO Numbers on Invoices, Searchable in Orders.
I finally got this mod to work on v4.4.4. It was not working when the po_number field in the database was set to VARCHAR. But when I changed it to text, it worked. Weird!
But thank you, Russell, for the great modification! |
Re: PO Numbers on Invoices, Searchable in Orders.
Having an issue with getting this to work.
I can insert a table entry for po_number manually, and it'll show up just fine in searches, etc. but as soon as I go to create a new order through xcart I get an error. Warning 403 Access denied ! You are not allowed to access that resource! Id: 79 This error no longer occurs if I remove: 'po_number' => addslashes(getPONum($order_details)), from func.order.php I've tried changing the dbtype to text from varchar, but that didn't help. |
Re: PO Numbers on Invoices, Searchable in Orders.
Is this working with 4.5.1 ?
|
Re: PO Numbers on Invoices, Searchable in Orders.
will this mode work on 4.5.2?
|
Re: PO Numbers on Invoices, Searchable in Orders.
Quote:
Hasn't been tested higher than 4.4.x (see notgrass' post above) but you could be the first! :-) |
Re: PO Numbers on Invoices, Searchable in Orders.
:-) This mod works great in 4.5.4 I'm using it
|
Re: PO Numbers on Invoices, Searchable in Orders.
Quote:
I hate bumping old threads, but I ran across this thread while trying to determine the reason for an almost identical error while modifying a module, and wanted to provide my solution. Clear the x-cart cache. It's that easy. I made a change to code that involves inserting data into a modified db table using the array2insert function built into x-cart. Apparently x-cart caches information about that table, and would throw this error when I'd provide 2 extra columns in the array. Clearing the cache solved it. |
All times are GMT -8. The time now is 01:28 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.