Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Purchase Order field for Customer
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 07-25-2003, 07:42 AM
 
jaymon jaymon is offline
 

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

Default Purchase Order field for Customer

I'm currently trying to add a Purchase Order# field into the checkout process so that customers can reference a PO# for there company. I would like this to show on the Order Invoice both for the customer and the Provider/Admin.

Has anyone done this mod on thier cart? I would like the PO field to be located in the payment part of the cart similar to the way that "Ship To:" is implemented. Anyone have an pointers on where to start?

TIA
__________________
--
Austin
Reply With Quote
  #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
  #3  
Old 08-28-2003, 08:52 AM
 
nuevojefe nuevojefe is offline
 

Member
  
Join Date: Jul 2003
Location: U.S.
Posts: 24
 

Default 3.4.3

I've been using 3.4.3 and I cannot get this to work no matter what I try. The only thing I have done is changed cust_po to rep_id, and purchase_order to sales_rep. But i've made the changes everywhere so there shouldn't be any problems.

The rep id box shows up on the payment page, however it is not included in the mailing nor is it on my admin orders printable page or the customers.

What am I doing wrong?

Could you please copy the source of your purchase_order.tpl?
Maybe my .tpl isn't formated correctly.

Thanks.
Reply With Quote
  #4  
Old 08-28-2003, 09:57 AM
 
jaymon jaymon is offline
 

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

Default Re: 3.4.3

Quote:
Originally Posted by nuevojefe
I've been using 3.4.3 and I cannot get this to work no matter what I try. The only thing I have done is changed cust_po to rep_id, and purchase_order to sales_rep. But i've made the changes everywhere so there shouldn't be any problems.

The rep id box shows up on the payment page, however it is not included in the mailing nor is it on my admin orders printable page or the customers.

What am I doing wrong?

Is it getting added to the database? If so, then it's a template display problem.

Quote:
Could you please copy the source of your purchase_order.tpl?
Maybe my .tpl isn't formated correctly.

Thanks.

It's at the top of the thread, but here it is again just in case.

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

FYI, I'm using Xcart version 3.3.3. So maybe the templates are different in the newer version you're using?
__________________
--
Austin
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:55 AM.

   

 
X-Cart forums © 2001-2018