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
  #51  
Old 04-03-2007, 02:18 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Printing 'Customer Notes' on invoices

Quote:
Originally Posted by rniejelski
Has anyone gotten this to work with Gift Certificates and also PayPal ?

Paypal uses payment_offline.php. Gift Certificates uses payment_giftcert.php. Modifying those should do the trick.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #52  
Old 06-17-2007, 10:30 PM
 
zebu zebu is offline
 

eXpert
  
Join Date: Oct 2006
Posts: 310
 

Default Re: Printing 'Customer Notes' on invoices

I got this to work on my version .19. A lot of the original code wasnt the same in my version - but its close enough to find your way around. Thanks to everone who put a lot of work into this.

Cheers Zane
__________________
Version 4.7.7
Reply With Quote
  #53  
Old 08-24-2007, 03:28 PM
  Vacman's Avatar 
Vacman Vacman is offline
 

X-Adept
  
Join Date: Sep 2005
Location: Torrance, CA
Posts: 792
 

Default Re: Printing 'Customer Notes' on invoices

Quote:
Originally Posted by cherie
I don't think it changes up to 4.0.19. It's unnecessary in 4.1.

Are you saying that notes are printed/included under 4.1.x?

If not - has anyone coded this out for 4.1.x?
__________________
Carl Tice

X-Cart 4.6.6
X-Payments 3.0
ReBOOT 3.4.1

PHP 5.6.30
MySQL 5.6.35
Linux 2.6.32-042stab120.18
ionCube PHP Loader v4.7.3
Perl 5.10.1
Reply With Quote
  #54  
Old 08-24-2007, 07:38 PM
 
zebu zebu is offline
 

eXpert
  
Join Date: Oct 2006
Posts: 310
 

Default Re: Printing 'Customer Notes' on invoices

Customer notes were not included on the invoice in 4.0.19. They are in 4.1.8 be default.
__________________
Version 4.7.7
Reply With Quote
  #55  
Old 08-24-2007, 08:03 PM
  Vacman's Avatar 
Vacman Vacman is offline
 

X-Adept
  
Join Date: Sep 2005
Location: Torrance, CA
Posts: 792
 

Default Re: Printing 'Customer Notes' on invoices

had not realized that - just tested it out you are correct! Very nice!
__________________
Carl Tice

X-Cart 4.6.6
X-Payments 3.0
ReBOOT 3.4.1

PHP 5.6.30
MySQL 5.6.35
Linux 2.6.32-042stab120.18
ionCube PHP Loader v4.7.3
Perl 5.10.1
Reply With Quote
  #56  
Old 09-12-2007, 12:56 PM
 
robertswww robertswww is offline
 

X-Adept
  
Join Date: Jul 2003
Posts: 586
 

Default Re: Printing 'Customer Notes' on invoices

Below, I prepared a Step-by-Step install guide for those using X-Cart version 4.0.19

Thanks to Cheri and Lucent88 for the meat of the code and Roblen, PHPdev and Loon for getting us started on this great mod!

I added additional details, line numbers and a few tweaks. It's a lot of files to change, but the changes are easy and this Mod will add this necessary element that was missing from the order management end. Plus, there's not a single SQL Patch! Just backup your site first, or work on a copy of the files involved.

What this Mod does: When the customer goes to Checkout and enters something in "Customer Notes", like special shipping instructions, those notes are encrypted along with the credit card information and written to the database. This information is typically hidden from your order fulfillment staff and does not appear on the customer's invoice. Below is a way to make the Customer Notes data independent of the Credit Card encryption and easily accessible to all necessary parties.

FYI: You can name the new field whatever you want to, just be consistent. Here's what 3 of us chose for the new field name:
Cherie: order_first
Lucent: order_comment
Robert: customer_comments

OPTIONAL: Change your language label via Admin-->Languages for "lbl_customer_notes" if you so desire...
My old Value: Customer notes
My new Value: <b>Customer Notes</b>


1. Locate File: include/func.php - add new field (customer_comments) to function: func_place_order (deep in code about line 2980+/-)

Find this Code:
Code:
# # This function creates order entry in orders table # function func_place_order($payment_method, $order_status, $order_details, $extra = array(), $extras = array()) {
Replace with this Code:
Code:
# # This function creates order entry in orders table # function func_place_order($payment_method, $order_status, $order_details, $customer_comments, $extra = array(), $extras = array()) {

2. Locate File: include/func.php (same file and function as above) - add "Customer_Comment" checkout form field name (about line 3160 +/-)

Find this Code:
Code:
if(!empty($extras)) {
Replace with this Code (added just above):
Code:
$extras['Customer_Comment'] = $customer_comments; if(!empty($extras)) {

3. Locate these 3 Files: payment/payment_cc.php (about line "78") AND payment/payment_offline.php (about line 46) AND payment_giftcert.php (about line 105 after "$order_details =$ship_to;") - (Note: to capture the user's input)

(NOTE: Paypal uses payment_offline.php)

Find this Code:
Code:
$order_details = "";
Replace with this Code (added just above):
Code:
$customer_comments = $Customer_Comment; $order_details = "";

4. Locate these 3 Files: payment/payment_cc.php AND payment/payment_offline.php AND payment/payment_giftcert.php (same files as above)

Find the Code that starts with: (Note: 2 areas in payment_cc.php AND 1 area in payment_offline.php AND 1 area in payment_giftcert.php)
Code:
$orderids = func_place_order

Add the field ($customer_comments) after $order_details

Code (payment_cc.php - around line "118"):
Code:
$orderids = func_place_order(stripslashes($payment_method)." (".$module_params["module_name"].(get_cc_in_testmode($module_params)?", in test mode":"").")", "I", $order_details, $customer_comments);

Code (payment_cc.php - around line 156):
Code:
$orderids = func_place_order(stripslashes($payment_method)." (manual processing)","Q",$order_details,$customer_comments);

Code (payment_offline.php - around line 64):
Code:
$orderids = func_place_order(stripslashes($payment_method),"Q",$order_details,$customer_comments);

Code (payment_giftcert.php - around line "108"):
Code:
$orderids = func_place_order(stripslashes($payment_method),"I",$order_details,$customer_comments);

*** Now the new field, Customer_Comment, is stored with the order in the order_extras table.

5. Locate File: skin1/customer/main/checkout_notes.tpl (around line 10)

Find this Code:
Code:
<TEXTAREA cols="45" rows="6" name="Customer_Notes"></TEXTAREA>

Replace with this Code:
Code:
<TEXTAREA cols="45" rows="6" name="Customer_Comment"></TEXTAREA>

6. Create a stripslashes smarty modifier: removes slashes directly from the template when extracting the Customer Comments/Notes.

*** NOTE: if you don't add "|sslash" to the end of your string variables that call the Customer Comments/notes, then if there is a quote or apostrophe in the customer's comment it will look like this: customer\'s comment.

First, create a new file and name it "modifier.sslash.php" save it to Smarty-2.6.9/plugins/ (note: I just duplicated the file, modifier.strip.php, then renamed it and replaced its contents with the new php code below)

Include this Code:
Code:
<?php function smarty_modifier_sslash($string) { return stripslashes($string); } ?>

7. Locate these 3 Files: skin1/mail/html/order_invoice.tpl AND order_customer_complete.tpl AND order_customer_processed.tpl

*** NOTE: code: {$order.extra.Customer_Comment|replace:"\n":" "|sslash} gets rid of customer line returns. To keep line returns use: {$order.extra.Customer_Comment|sslash}, but this will stretch out the invoice (horizontally) if there is a single long sentence from the customer.

Locate File: skin1/mail/html/order_invoice.tpl (to include Customer Comments/notes in Order Invoice)

Find this Code (around line 304):
Code:
{if $config.Email.show_cc_info eq "Y" and $show_order_details eq "Y"}

Replace with this Code (added just above):
Code:
<TR> <TD colspan="3">&nbsp;<BR>{$lng.lbl_customer_notes}:<BR>{$order.extra.Customer_Comment|replace:"\n":" "|sslash}</TD> </TR> {if $config.Email.show_cc_info eq "Y" and $show_order_details eq "Y"}

Optional: To include Customer Comments/notes in the Order Complete and Order Processed emails sent to the customer...
Locate these 2 Files: order_customer_complete.tpl AND order_customer_processed.tpl

Find this Code (around line 40):
Code:
<TR> <TD colspan="3">{include file="mail/html/order_data.tpl"}</TD> </TR> </TABLE>

Replace with this Code (added just above):
Code:
<TR><TD>{$lng.lbl_customer_notes}:</TD></TR> <TR><TD colspan="3">{$order.extra.Customer_Comment|replace:"\n":" "|sslash}</TD></TR> <TR><TD>&nbsp;<P></TD></TR> <TR> <TD colspan="3">{include file="mail/html/order_data.tpl"}</TD> </TR> </TABLE>

8. Locate File: skin1/main/history_order.tpl (around line 90)

Find this Code:
Code:
<P> {$lng.lbl_order_details}:<BR> <TEXTAREA name="details" cols="70" rows="8">{$order.details|escape:quotes}</TEXTAREA>
Replace with this Code (added just above):
Code:
<P> {$lng.lbl_customer_notes}: {if $usertype ne "C"} (visible to customer and provider) {/if}<BR> <textarea name="Customer_Comment" cols="70" rows="8">{$order.extra.Customer_Comment|sslash}</textarea> {if $usertype eq "A" or ($usertype eq "P" and $active_modules.Simple_Mode)} <P> {$lng.lbl_order_details}:<BR> <TEXTAREA name="details" cols="70" rows="4">{$order.details|escape:quotes}</TEXTAREA> {/if}

9. Locate File: admin/order.php - Make admin able to edit Customer's Comment/note in the status_change mode section before func_header_location. If you don't want the admin to be able to edit the Customer's Comments/notes, then add "readonly" (without quotes) to the end of the opening textarea tag in Step 8 (see Step 10 for an example).

Find this Code (around line 134):
Code:
func_change_order_status($orderid, $status); func_header_location("order.php?orderid=$orderid&mode=status_changed"); }
Big original code Flaw discovered and Fixed here:
If you go into Admin and change the Status of an order and add a Customer Comment/Note to an existing note, it works fine, but if there is NO existing note and therefore NO khash='Customer_Comment' field, then your new Admin note will NOT get added... here is the updated code to check if the 'Customer_Comment' field exists, if Yes, the updated comment is added to the Old (existing) Comments and Inserted into the DB table, if NO, the DB table is Updated to add the field and the comment:

Replace with this Code (added just above):
Code:
$customer_comments = addslashes($Customer_Comment); $oldcomments = db_query("SELECT value FROM $sql_tbl[order_extras] WHERE orderid='$orderid' AND khash='Customer_Comment'"); if ($oldcommentsexist = mysql_fetch_array($oldcomments)) { db_query("UPDATE $sql_tbl[order_extras] SET value='$customer_comments' WHERE orderid='$orderid' AND khash='Customer_Comment'"); } else { db_query("INSERT INTO $sql_tbl[order_extras] (orderid, khash, value) VALUES ('$orderid', 'Customer_Comment', '$customer_comments')"); } func_change_order_status($orderid, $status); func_header_location("order.php?orderid=$orderid&mode=status_changed"); }

10. OPTIONAL: For AOM users only (to see notes), Locate File: skin1/modules/Advanced_Order_Management/preview.tpl

Add this Code:
Code:
<textarea name="Customer_Comment" cols="60" rows="5" readonly>{$order.extra.Customer_Comment|sslash}</textarea>

11. OPTIONAL - Gift Cert Fix If you would like to integrate the additional code to fix the Gift Cert notes flaw, continue with my Post #60 below.

That's it... good luck!
Robert

Note: Updated Steps 1, 3, 8 & 9 on Oct. 6, 2007
__________________
X-cart 4.1.10
Reply With Quote
  #57  
Old 09-12-2007, 01:27 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Printing 'Customer Notes' on invoices

Great recap! It all looks good!
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #58  
Old 09-12-2007, 04:04 PM
 
robertswww robertswww is offline
 

X-Adept
  
Join Date: Jul 2003
Posts: 586
 

Default Re: Printing 'Customer Notes' on invoices

Quote:
Originally Posted by cherie
Great recap! It all looks good!
Thanks Cherie!

We have been using this code with great success for the past few weeks, and it has been a huge help to the order processing department.

So far, we have only encountered one quirk...

If you pay via Gift Certificate and enter Customer Comments/Notes, but your GC doesn't cover the total amount and then you select Credit Card and finish the Checkout and add a 2nd set of Customer Comments/Notes on the Credit Card Checkout page, only the 2nd Set of notes will be saved and show on the invoice.

Do you know how to adapt the code in this particular instance, that if a note exists, to append the 2nd note (from the same order id) onto the end of the 1st note, instead of overwriting it?
__________________
X-cart 4.1.10
Reply With Quote
  #59  
Old 09-12-2007, 04:18 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Printing 'Customer Notes' on invoices

Quote:
Originally Posted by robertswww
Thanks Cherie!

We have been using this code with great success for the past few weeks, and it has been a huge help to the order processing department.

So far, we have only encountered one quirk...

If you pay via Gift Certificate and enter Customer Comments/Notes, but your GC doesn't cover the total amount and then you select Credit Card and finish the Checkout and add a 2nd set of Customer Comments/Notes on the Credit Card Checkout page, only the 2nd Set of notes will be saved and show on the invoice.

Do you know how to adapt the code in this particular instance, that if a note exists, to append the 2nd note (from the same order id) onto the end of the 1st note, instead of overwriting it?

I think I've addressed that in the past but don't have the code handy. Basically what I did was keep the Customer Notes along and resubmit them (hidden) with the alternate payment method so the notes were still there. That's the direction I would head. This is actually a problem with the default X-Cart and not necessarily specific to this mod. Definitely something worth trying to improve.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #60  
Old 10-06-2007, 08:15 AM
 
robertswww robertswww is offline
 

X-Adept
  
Join Date: Jul 2003
Posts: 586
 

Default Re: Printing 'Customer Notes' on invoices

Quote:
Originally Posted by cherie
I think I've addressed that in the past but don't have the code handy. Basically what I did was keep the Customer Notes along and resubmit them (hidden) with the alternate payment method so the notes were still there. That's the direction I would head. This is actually a problem with the default X-Cart and not necessarily specific to this mod. Definitely something worth trying to improve.
With my brother's programming help we have fixed this problem.

Before the fix:
If a customer pays via Gift Certificate, enters a Customer Comment/Note, but the gift cert doesn't cover the total amount due, so another payment method is chosen, the notes are lost when you are taken to the 2nd payment method screen, because the order has not yet been completed, and therefore doesn't yet have an Order ID and hasn't yet had its info stored to the DataBase.

After the fix:
Basically, the notes from the first Gift Cert submission are stored in the variable gc_notes1 (which is set equal to $Customer_Comment). I then assign gc_notes to equal gc_notes1 (via Smarty) and later echo the gc_notes in the textarea (via PHP). To pass the variable (that holds the notes) involves a combination of PHP and Smarty code.


Step 1:
Locate this File: payment/payment_giftcert.php –(about line 137) - to pass variable to Cart.php in URL
Find this code: (at the end of the file)
Code:
else { # # Not enough money # func_header_location($current_location.DIR_CUSTOMER."/cart.php?mode=checkout"); } } ?>
Replace with this code:
Code:
else { # # Not enough money # # NOTE - appended "gc_notes1" variable (Gift Certificate Notes) onto the end of the URL to pass along the Customer Comments/Notes func_header_location($current_location.DIR_CUSTOMER."/cart.php?mode=checkout&gc_notes1=".urlencode($Customer_Comment)); } } ?>

Step 2:
Locate this File: cart.php - (about line 797):
Find this code:
Code:
func_header_location("cart.php?paymentid=".$payment_methods[0]["paymentid"]."&mode=checkout");
Replace with this code: (added just above to assign variable to Smarty)
Code:
$smarty->assign("gc_notes", $gc_notes1); func_header_location("cart.php?paymentid=".$payment_methods[0]["paymentid"]."&mode=checkout");

Step 3:
Locate this File: skin1/customer/main/checkout.tpl - (about line 133) - to append variable to 2nd Checkout URL

Find this code:
Code:
<INPUT type="hidden" name="mode" value="checkout">
Replace with this code: (added just below)
Code:
<INPUT type="hidden" name="mode" value="checkout"> {if $gc_notes ne ""} <INPUT type="hidden" name="gc_notes" value="{$gc_notes}"> {/if}

Step 4:
Locate this File: skin1/customer/main/checkout_notes.tpl - (about line 133) - to put GC notes in 2nd payment notes box:
Find this code:
Code:
<TEXTAREA cols="45" rows="6" name="Customer_Comment"></TEXTAREA>
Replace with this code: (variable inserted into textarea)
Code:
<TEXTAREA cols="45" rows="6" name="Customer_Comment">{php} if($_GET['gc_notes'] > ""){echo $_GET['gc_notes'];} {/php}</TEXTAREA>

NOTE: This is tested in X-Cart 4.0.19.
I also made other updates to the code in my post #56 above.
If you are going to integrate this MOD, follow post #56 first, then follow this post #60.

Robert
__________________
X-cart 4.1.10
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 08:44 PM.

   

 
X-Cart forums © 2001-2020