View Single Post
  #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