View Single Post
  #2  
Old 07-29-2003, 06:57 AM
 
jaymon jaymon is offline
 

Member
  
Join Date: Sep 2002
Location: St. Louis
Posts: 16
 

Default

Sorry, replying to my own thread. At least I'm posting a mod, huh?

********* Template Code *************

Create a new template for the invoice field at checkout time. I created a file called /skin1/customer/main/purchase_order.tpl and put the following in that file:

Code:
Company P.O.#: <input type=text name=cust_po size=30 maxlength=32 value="">


Then edit /skin1/customer/main/customer_details.tpl like this below:

Code:
Personal information: --------------------- First Name: {$userinfo.firstname} Last Name: {$userinfo.lastname} Phone: {$userinfo.phone} Fax: {$userinfo.fax} E-Mail: {$userinfo.email} Company: {$userinfo.company} {include file="customer/main/purchase_order.tpl"} Job Title: {$userinfo.jobtitle} Web site: {$userinfo.url} Billing Address: ---------------- Address: {$userinfo.b_address} City: {$userinfo.b_city} State: {$userinfo.b_statename} Country: {$userinfo.b_countryname} Zip code: {$userinfo.b_zipcode} Shipping Address: ----------------- {include file="customer/main/ship_to.tpl"} Address: {$userinfo.s_address} City: {$userinfo.s_city} State: {$userinfo.s_statename} Country: {$userinfo.s_countryname} Zip code: {$userinfo.s_zipcode}

To display it in the orders admin screen edit /skin1/main/history_order.tpl and look for:

Code:
<tr> <td valign="top">Quantity</td> <td valign="top">{$products[prod_num].amount} item(s)</td> </tr>

Add this below:

Code:
{* If there's a purchase order in the xcart_orders table, display it *} {if $order.purchase_order ne ""} <tr> <td valign="top">Customer Purchase Order #</td> <td valign="top">{$order.purchase_order}</td> </tr> {/if}

To add it to the printable invoice (/skin1/main/order_invoice_print.tpl), add this below:

Code:
{if $order.purchase_order ne ""}Purchase Order #: {$order.purchase_order}{/if}

********** Backend Code **************

Add a new field to the xcart_orders table.

Code:
ALTER TABLE `xcart_orders` ADD `purchase_order` VARCHAR( 32 ) NOT NULL

Modify /include/payment_method.php and look for the line:
Code:
if(empty($ship_to)) { $ship_to=""; if ($Ship_To_name !="") $ship_to.="\nShip to: ".$Ship_To_name; }

Add this below that line.

Code:
# # Added the Purchase Order check, if present, add cust_po to $userinfo # if ($cust_po !="") $userinfo.=$cust_po;

Then modify /includes/func.php around line 1157. (should be all one line. Watch out for line wrap). This is where order info gets put into the database. We need to add our new table field (purhcase_order) and grab the cust_po out of $userinfo to add to the database.
Code:
db_query("insert into $sql_tbl[orders] (login, total, giftcert_discount, giftcert_ids, subtotal, shipping_cost, shippingid, tax, discount, coupon, coupon_discount, date, status, payment_method, flag, details, title, firstname, lastname, company, jobtitle, b_address, b_city, b_state, b_country, b_zipcode, s_address, s_city, s_state, s_country, s_zipcode, phone, fax, email, url, purchase_order) values ('".addslashes($userinfo["login"])."', '$current_order[total_cost]', '$giftcert_discount', '$giftcert_str', '$current_order[sub_total]','$current_order[shipping_cost]', '$cart[shippingid]', '$current_order[tax_cost]', '$current_order[discount]', '".addslashes($current_order[coupon])."', '$current_order[coupon_discount]', '".time()."', '$order_status', '".addslashes($payment_method)."', 'N', '".addslashes(text_crypt($order_details))."', '".addslashes($userinfo["title"])."', '".addslashes($userinfo["firstname"])."', '".addslashes($userinfo["lastname"])."', '".addslashes($userinfo["company"])."', '".addslashes($userinfo["jobtitle"])."', '".addslashes($userinfo["b_address"])."', '".addslashes($userinfo["b_city"])."', '".addslashes($userinfo["b_state"])."', '".addslashes($userinfo["b_country"])."', '".addslashes($userinfo["b_zipcode"])."', '".addslashes($userinfo["s_address"])."', '".addslashes($userinfo["s_city"])."', '".addslashes($userinfo["s_state"])."', '".addslashes($userinfo["s_country"])."', '".addslashes($userinfo["s_zipcode"])."', '".addslashes($userinfo["phone"])."', '".addslashes($userinfo["fax"])."', '$userinfo[email]', '".addslashes($userinfo["url"])."', '".addslashes($userinfo["cust_po"])."')");

Let me know if anyone sees any holes or problems with this mod. So far it's working well for me. I'm using Xcart Version 3.3.3, use at your own risk, YMMV, etc.
__________________
--
Austin
Reply With Quote