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

Printing 'Customer Notes' on invoices

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 03-26-2004, 11:55 AM
 
Loon Loon is offline
 

Member
  
Join Date: Feb 2004
Location: MN, USA
Posts: 19
 

Default Printing 'Customer Notes' on invoices

When the customer goes to Checkout and selects a payment method of Credit Card, then enters something in "customer notes", like special shipping instructions, those notes are encrypted along with the credit card information and written in the database.

We found them hard to read and easy to miss when embedded in the credit card information on the Admin / Orders screen. We also wanted to print these instructions on the customer's invoice and Not print the credit card information.

I've put together a modification that will do this. It basically replicates those "customer notes" to the xcart-orders.notes field in the database, making it easy to read back and print where we want.

We are on x-cart version 3.5.4 and using Authorizenet / AIM for Credit Card processing. I will install this change tonight and if all goes well, will post the instructions tomorrow, if anyone is interested?
__________________
Linux / Apache 1.3.31
PHP 4.3.3
MySQL 4.0.18
X-Cart 3.5.4 in production Mar 08, 2004
X-Cart 3.5.4 Win2k SP4 for development
Reply With Quote
  #2  
Old 03-27-2004, 11:08 AM
  caucus's Avatar 
caucus caucus is offline
 

eXpert
  
Join Date: Oct 2003
Location: FLorida U.S.A
Posts: 356
 

Default

Hello I am using Sim and AN. It would be nice to know how to do this. I could never understand why we could not pass the notes in the e-mail. The sales department gets the e-mail and never do get the customer notes. What a bad system. Customer note shold be for customer notes no the the CC information.
__________________
Staying To The Right
But Left of Rush

X-cart Current version: 4.4.2
X-cart Current version: 4.4.1
X-cart Version 4.0.14
X-cart Version 4.1.6
Litecomm Version: 2.2.35
Operating System Linux
PHP Version 5.2.14
Apache/2.2.16 (Unix)
MySQL client version: 5.091
Reply With Quote
  #3  
Old 03-27-2004, 11:13 AM
 
Loon Loon is offline
 

Member
  
Join Date: Feb 2004
Location: MN, USA
Posts: 19
 

Default

Hi -- I installed our "fix" last night and all is well. As soon as I finish another little project, I'll post the changes I made.

Our notes were there, but buried in the little box with the CC info on the Admin / Orders page and Very Easily overlooked.

Give me an hour and I'll have the details up here.
__________________
Linux / Apache 1.3.31
PHP 4.3.3
MySQL 4.0.18
X-Cart 3.5.4 in production Mar 08, 2004
X-Cart 3.5.4 Win2k SP4 for development
Reply With Quote
  #4  
Old 03-27-2004, 12:17 PM
 
Loon Loon is offline
 

Member
  
Join Date: Feb 2004
Location: MN, USA
Posts: 19
 

Default

The scenario:
Customer clicks on "CheckOut"
Selects credit card for method of payment and clicks on "Continue"
Below the fields for the credit card information is a textbox for "Customer Notes".
When the order is submitted, the "Customer Notes" get encrypted along with the credit card data and are placed in the x-cart_orders.details field of the database.
When you view an individual order in the Admin / Orders section of the cart, the little box titled: "Order details (not visible to customer and provider):" has the "Customer Notes" in it, but they're buried in the middle of the credit card data. We didn't even find them for a week!
The field below the Order Details, can be used by the admin or order filler to write notes and this second field is stored in the x-cart_orders.notes field in the database but not printed anywhere.

So, my solution:
1. Signed in as an admin, under Administration / Languages / the label "lbl_order_notes" reads "Order Instructions (not visible to customer)".
I changed the Value to read "Special Instructions" but left the label variable name alone.

2. [x-cart root dir]/skin1/main/history_order.tpl, I enlarged both the Order Details and (now) Special Instructions textboxes, to maintain my sanity.


Code:
{if $usertype eq "A"} {$lng.lbl_order_details}: <textarea name=details cols=100 rows=15>{$order.details}</textarea> {/if} {if $usertype ne "C"} {$lng.lbl_order_notes}: <textarea name=notes cols=100 rows=8>{$order.notes}</textarea> {/if}
Just increase the cols= and rows= until it's easier to read the contents of the boxes.

3. [x-cart root dir]/payment/payment_cc.php
I added a new variable, $order_notes, to store the information that the customer entered in "Customer Notes". This is already in the $order_details variable but that's the one that gets encrypted and I didn't want to deal with stripping information out of that block.
Near the top of the file, find $order_details = ""; and simply add the new variable under it.
Code:
$order_details = ""; $order_notes = "";


A few lines further in the same file, set the value of the new $order_notes.
Code:
$order_details.=$ship_to; $order_details.="\nCustomer notes: ".$Customer_Notes; $order_notes = $Customer_Notes;
The first two lines above should be there, just add the third line.

Again in the same file, around line 67, look for the comment # Put order in table
Code:
# Put order in table if(empty($secure_oid) || ($secure_oid_cost != $cart["total_cost"])) { $orderids = func_place_order("$payment_method (".(get_cc_in_testmode($module_params)?"in test mode":"")."Card type: $card_type".")", "I", $order_details,$order_notes); $secure_oid = $orderids; $secure_oid_cost = $cart["total_cost"]; $duplicate = false;
Notice the addition of ,$order_notes to the end of the initialization of $orderids. We have modified this line to show the credit card type (Card type: Visa) rather just Authorizenet, so your line may look a little different.

Same file still, around line 95, add the new variable again after $order_details:
Code:
# # If active_processor is empty do manual processing # $orderids = func_place_order($payment_method." (manual processing)","Q",$order_details,$order_notes);

That should be all for this file.

4. [x-cart root dir]/include/func.php
Around line 2132, you need to add the new variable, $order_notes to the insert query so it's saved when a new order gets added to the database.
Code:
# # This function creates order entry in orders table # function func_place_order($payment_method, $order_status, $order_details, $order_notes) {
Notice ,$order_notes added to the end of the arguments to func_place_order.

Now the ugly one, but Very little change (we're still in func.php):
Code:
# # Insert into orders # db_query("insert into $sql_tbl[orders] (login, membership, total, giftcert_discount, giftcert_ids, subtotal, shipping_cost, shippingid, tax, tax_gst, tax_pst, total_vat, taxes_applyed, discount, coupon, coupon_discount, date, status, payment_method, flag, details, title, firstname, lastname, company, b_title, b_firstname, b_lastname, b_address, b_city, b_state, b_country, b_zipcode, s_title, s_firstname, s_lastname, s_address, s_city, s_state, s_country, s_zipcode, phone, fax, email, url, reg_numbers, notes, vat_applied) values ('".addslashes($userinfo["login"])."', '".addslashes($userinfo["membership"])."', '$current_order[total_cost]', '$giftcert_discount', '".@$giftcert_str."', '$current_order[subtotal]','$current_order[shipping_cost]', '$cart[shippingid]', '$current_order[tax_cost]', '$current_order[tax_gst]', '$current_order[tax_pst]', '$current_order[total_vat]', '$taxes_applyed', '$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["b_title"])."', '".addslashes($userinfo["b_firstname"])."', '".addslashes($userinfo["b_lastname"])."', '".addslashes($userinfo["b_address"])."', '".addslashes($userinfo["b_city"])."', '".addslashes($userinfo["b_state"])."', '".addslashes($userinfo["b_country"])."', '".addslashes($userinfo["b_zipcode"])."', '".addslashes($userinfo["s_title"])."', '".addslashes($userinfo["s_firstname"])."', '".addslashes($userinfo["s_lastname"])."', '".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"])."', '$reg_numbers', '".addslashes($order_notes)."', '$current_order[vat_applied]')");
** in the list of fields, added 'notes' right after reg_numbers:
......,reg_numbers, notes, vat_applied) values.......

and in the values list, added our new variable in the same position near the end:
......., '$reg_numbers', '".addslashes($order_notes)."', '$current_order[vat_applied]')");......

Look for reg_numbers in the query and just add the additional field to the two places.

5. [x-cart root dir]/skin1/mail/order_invoice.tpl
Added two new lines to print the label "Special Instructions:" and the data that we saved above in xcart_orders.notes.
Code:
{$lng.lbl_order_notes}: {$order.notes|wordwrap:80|indent:2}
We put this after the shipping address section but you can place where you want. This will cause our "new" field to print on the invoices. I have the text wrapping at 80 characters and the paragraph of text will be indented 2 spaces, but the label is not indented.

6. YOU'RE DONE. I apologize for the length but hoped to make it clear and easy to follow.
__________________
Linux / Apache 1.3.31
PHP 4.3.3
MySQL 4.0.18
X-Cart 3.5.4 in production Mar 08, 2004
X-Cart 3.5.4 Win2k SP4 for development
Reply With Quote
  #5  
Old 03-27-2004, 01:17 PM
  caucus's Avatar 
caucus caucus is offline
 

eXpert
  
Join Date: Oct 2003
Location: FLorida U.S.A
Posts: 356
 

Default

Hello Loon

Wow, I am going to print this out and give it a try. I am a bit slow on this type of things. However I think your instructions are very easy to follow. I will give it an attempt.

I wonder why Xcart does not make the customer note used for customer notes only. Then they can be sent anywhere. without a problem. That is another story.

Thank you for your help and time on passing this information on.
__________________
Staying To The Right
But Left of Rush

X-cart Current version: 4.4.2
X-cart Current version: 4.4.1
X-cart Version 4.0.14
X-cart Version 4.1.6
Litecomm Version: 2.2.35
Operating System Linux
PHP Version 5.2.14
Apache/2.2.16 (Unix)
MySQL client version: 5.091
Reply With Quote
  #6  
Old 03-27-2004, 01:38 PM
 
Loon Loon is offline
 

Member
  
Join Date: Feb 2004
Location: MN, USA
Posts: 19
 

Default

You're very welcome. Hope it goes well. I forgot to mention that when you view the individual order in admin, if you want, you can add more comments to the "special instructions" and click "modify", then print the invoice and they'll all be there. We find it useful to elaborate on the instructions from the customer ocassionally so the order filler knows what to do.

Good luck! Jean
__________________
Linux / Apache 1.3.31
PHP 4.3.3
MySQL 4.0.18
X-Cart 3.5.4 in production Mar 08, 2004
X-Cart 3.5.4 Win2k SP4 for development
Reply With Quote
  #7  
Old 04-07-2004, 08:34 AM
 
PHPdev PHPdev is offline
 

Member
  
Join Date: Oct 2003
Posts: 18
 

Default

I would like to extend my thanks for these nicely written directions, and offer up one addition. If you accept any offline payment methods such as money orders you will need to make a change to the [x-cart root dir]/payment/payment_offline.php file.

Quote:
4. [x-cart root dir]/include/func.php
Around line 2132, you need to add the new variable, $order_notes to the insert query so it's saved when a new order gets added to the database.
Code:
Code:
# # This function creates order entry in orders table # function func_place_order($payment_method, $order_status, $order_details, $order_notes) {
Notice ,$order_notes added to the end of the arguments to func_place_order.

If you change the function definition to
Code:
# # This function creates order entry in orders table # function func_place_order($payment_method, $order_status, $order_details, $order_notes="") {

NOTE: the addtion of ' = "" ' after the $order_notes

this should elminate any potential issues if this function is called and a $order_notes variable is not included.

PAYMENT_OFFLINE.php

This file does not appear to check for Customer Notes to place in the $order_detials so we have to do a little more changing.

Code:
foreach($HTTP_POST_VARS as $key=>$val) if ($key!="action" && $key!="payment_method" && $key!=$XCART_SESSION_NAME and $val!="") if ($key=="Ship_To_name") $order_details.="Ship to: $val\n"; else $order_details.=str_replace("_"," ",$key)." : $val\n";

Becomes

Code:
foreach($HTTP_POST_VARS as $key=>$val) if ($key!="action" && $key!="payment_method" && $key!=$XCART_SESSION_NAME and $val!="") if ($key=="Ship_To_name") $order_details.="Ship to: $val\n"; elseif($key=="Customer_Notes") $order_notes = "Customer Notes: $val"; else $order_details.=str_replace("_"," ",$key)." : $val\n";

NOTE the addition of elseif($key=="Customer_Notes") $order_notes = "Customer Notes: $val";

THEN

Code:
# # $payment_method is variable which ss POSTed from checkout.tpl # $orderids = func_place_order($payment_method,"Q",$order_details);

Needs the addition of the $order notes variable

Code:
# # $payment_method is variable which ss POSTed from checkout.tpl # $orderids = func_place_order($payment_method,"Q",$order_details, $order_notes);


And thats all folks

Thanks
__________________
PHPdev

---------------------
X-Cart: 4.1.11
OS: Linux
Apache: 2.0.61
Reply With Quote
  #8  
Old 04-07-2004, 08:46 AM
 
Loon Loon is offline
 

Member
  
Join Date: Feb 2004
Location: MN, USA
Posts: 19
 

Default

Excellent addition, thank You!
We aren't taking anything other than CC orders at the moment so I didn't pursue changing this part but am happy to see it works there also.
__________________
Linux / Apache 1.3.31
PHP 4.3.3
MySQL 4.0.18
X-Cart 3.5.4 in production Mar 08, 2004
X-Cart 3.5.4 Win2k SP4 for development
Reply With Quote
  #9  
Old 07-01-2004, 11:25 AM
 
Seppo Seppo is offline
 

Newbie
  
Join Date: Jun 2004
Location: NC
Posts: 1
 

Default

I tried this mod and my order_notes comes out encrypted on the email and in the admin order detail. Any ideas why?
__________________
Keith

X-Cart v3.4.14
Reply With Quote
  #10  
Old 07-01-2004, 11:28 AM
  adpboss's Avatar 
adpboss adpboss is offline
 

X-Man
  
Join Date: Feb 2003
Location: Ontario, Canada
Posts: 2,389
 

Default

Blowfish encryption was added to the order notes field around version 3.5.6.

This mod would have to be reworked to allow decryption of the order notes for printing.

It has become much more complicated.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



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 05:25 PM.

   

 
X-Cart forums © 2001-2020