Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[contribution] Print Order Receipt


Recommended Posts

I could not find a thread for this contribution, so I am resurrecting it from the past.

 

Contribution: Print Order Receipt Ver. 1.4

http://www.oscommerce.com/community/contributions,2379

 

I have installed the contribution and it works very well. Thank you to the original authors!

 

I have made one enhancement, and have one bug that I need help to fix.

 

I improved the way the Payment Method appears. rather than just a generic "Paid by credit card", use the following code to show the payment method, specific card type, and first and last 4 digits of the credit card. Much nicer.

 

In catalog/print_order.php and catalog/print_order2.php

 

FIND:

<td class="main"><?php echo $order->info['payment_method']; ?> </td>

 

REPLACE WITH:

				<!--<td class="main"><?php // echo $order->info['payment_method']; ?> </td> -->
<?php // Better payment info ?>
<?php
 if (tep_not_null($order->info['cc_number']))  {
$this->cc_card_number_less_middle_digits = substr($order->info['cc_number'], 0, 4) . str_repeat('x', (strlen($order->info['cc_number']) - 8)) . substr($order->info['cc_number'], -4);
?>
				 		   <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b> <?php echo $order->info['payment_method']; ?> (<?php echo $order->info['cc_type']; ?>)<br><b><?php echo ENTRY_PAYMENT_CC_NUMBER; ?></b> <?php echo $this->cc_card_number_less_middle_digits; ?><br><?php echo tep_draw_separator('pixel_trans.gif', '100%', '6'); ?></td>
<?php
 } else {
?>
				 		   <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b> <?php echo $order->info['payment_method']; ?></td>
<?php
 }
?>
<?php // END Better payment info ?>

 

 

 

The bug fix I need help with has to do with the order number appearing

 

In catalog/print_order.php the order number appears correctly. (this is the one viewed from My Account->Order history->Print Invoice)

 

In catalog/print_order2.php (viewed from Checkout_Success) the order number does not appear at all

 

 

Any help appreciated

-Dave

Link to comment
Share on other sites

  • Replies 53
  • Created
  • Last Reply

Top Posters In This Topic

print_order2.php has an error in the display of the order number.

 

Find:

<td class="main" colspan="2"><b><?php // echo sprintf(HEADING_ORDER_NUMBER, $HTTP_GET_VARS['order_id']) . ' <small>(' . $order->info['orders_status'] . ')</small>'; ?></b></td>

 

Change to:

<td class="main" colspan="2"><b><?php echo sprintf(HEADING_ORDER_NUMBER, $HTTP_GET_VARS['oID']) . ' <small>(' . $order->info['orders_status'] . ')</small>'; ?></b></td>

 

the order number will now show properly

Edited by Roaddoctor

-Dave

Link to comment
Share on other sites

  • 3 weeks later...

David,

Thanks for the update! Do I need to install all the other updates besides yours, or is 1.5 a complete package as far as the file modifications go? I'm thinking I'll at least have to do the original, but what about v1.2, 1.3, 1.4, and 1.5

sorry about the confusion but I'm a NUB on this. and I would rather get it right the first time.

Thanks,

Henry

Link to comment
Share on other sites

David,

Thanks for the update! Do I need to install all the other updates besides yours, or is 1.5 a complete package as far as the file modifications go? I'm thinking I'll at least have to do the original, but what about v1.2, 1.3, 1.4, and 1.5

sorry about the confusion but I'm a NUB on this. and I would rather get it right the first time.

Thanks,

Henry

 

1.5 is the complete package. No need to start with earlier version

-Dave

Link to comment
Share on other sites

  • 1 month later...

I certainly must have done something wrong because on both of the options I get blank pages.

 

print_order.php.html.jpg

 

print_order2.php.html.jpg

 

I went back through the instructions and found this. Is this where I made my mistake.

The "should look like this" doesn't seem to give the results the instructions indicate.

 

Am I misinterpreting it?

 

################################################################################

#########

in checkout_process.php

 

right after....

 

$order_products_id = tep_db_insert_id();

 

ADD...

 

//begin add receipt//

tep_session_register('last_order');

$last_order = $insert_id;

$oID = $last_order;

//end add receipt//

 

________________________________________

should look like this....

 

tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

//begin add receipt//

tep_session_register('last_order');

$last_order = $insert_id;

$oID = $last_order;

//end add receipt//

________________________________________

################################################################################

##########

Just between us, remember there are only 10 kinds of people in the world; those who understand binary and those who don't!!

 

Remember, learning is a "do-it-yourself" experience; although, not necessarily a "do-it-BY-yourself" experience.

 

The quickest way to learn is to forget to BACKUP!

Link to comment
Share on other sites

I followed the instructions and now get an error message as below:

 

Fatal error: Call to a member function on a non-object in /home/morones5/public_html/test/checkout_process.php on line 203

Do or Do Not, there is no try.

Link to comment
Share on other sites

I followed the instructions and now get an error message as below:

 

Fatal error: Call to a member function on a non-object in /home/morones5/public_html/test/checkout_process.php on line 203

Nevermind, I was able to get the Print Order Receipt Contribution to work. There was a misunderstanding in the installation docs.

Thank you. Great contribution.

Do or Do Not, there is no try.

Link to comment
Share on other sites

Thanks for the contribution. I'm getting this error "popupPrintReceipt is not defined" [break on this error] null

print_order2.php (line 1) in the Firefox Firebug console.

 

I recall installing this as version 1.4 without these errors some time ago.

 

Any help is appriciated.

Link to comment
Share on other sites

  • 2 months later...

Hello,

 

I don't seem to be getting out the credit card information in print_order2.php. Just getting the generic "Credit Card Payments".

 

I have installed version 1.5, which has the update in it to get the credit card information printed. Do you need to be storing the credit card information in your db in order for this to work?

 

I was also trying to get the comments/special instructions to show up on the invoice/receipt, but it always seems to come out blank. I was using this value:

$order->info['comments'] to display the comments. It looked like orders.php was setting up the comments field, but nothing is being displayed.

 

Anyone with any suggestions on either issue?

 

Thanks

Link to comment
Share on other sites

hey, I'm getting a few problems:

 

1. On the account_history_info.php page, the order details are showing, except only the "U" in USA is showing for the country

2. On the pop-up print ready page, the same "u" thing is happening

3. on that print page, under Billing Info, it says "Payment Method", but nothing is showing up underneath that

4. Also, I'm getting the following error above the billing address:

 

"Fatal error: Using $this when not in object context in /home/showkur8/public_html/lvf/vitaminshop/print_order.php on line 181"

 

Any thoughts?

 

Thx!

Link to comment
Share on other sites

I certainly must have done something wrong because on both of the options I get blank pages.

 

print_order.php.html.jpg

 

print_order2.php.html.jpg

 

I went back through the instructions and found this. Is this where I made my mistake.

The "should look like this" doesn't seem to give the results the instructions indicate.

 

Am I misinterpreting it?

 

The correct "should look like this" - at least in my file

checkout_process.php

 

// Update products_ordered (for bestsellers list)
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");

$sql_data_array = array('orders_id' => $insert_id, 
						'products_id' => tep_get_prid($order->products[$i]['id']), 
						'products_model' => $order->products[$i]['model'], 
						'products_name' => $order->products[$i]['name'], 
						'products_price' => $order->products[$i]['price'], 
						'final_price' => $order->products[$i]['final_price'], 
						'products_tax' => $order->products[$i]['tax'], 
						'products_quantity' => $order->products[$i]['qty']);
tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
$order_products_id = tep_db_insert_id();
//begin add receipt//
tep_session_register('last_order');
 $last_order = $insert_id;
 $oID = $last_order;
//end add receipt//

-Dave

Link to comment
Share on other sites

hey, I'm getting a few problems:

 

1. On the account_history_info.php page, the order details are showing, except only the "U" in USA is showing for the country

2. On the pop-up print ready page, the same "u" thing is happening

3. on that print page, under Billing Info, it says "Payment Method", but nothing is showing up underneath that

4. Also, I'm getting the following error above the billing address:

 

"Fatal error: Using $this when not in object context in /home/showkur8/public_html/lvf/vitaminshop/print_order.php on line 181"

 

Any thoughts?

 

Thx!

 

1. My entries say United States, not USA or US so I have no idea

2. See #1

3. Does your copy of printorder.php look like this around line 174 to 192

				<td class="main"><b><?php echo HEADING_PAYMENT_METHOD; ?></b></td>
		  </tr>
		  <tr>
			<!--<td class="main"><?php // echo $order->info['payment_method']; ?> </td> -->
<?php // Better payment mod by BFD ?>
<?php
 if (tep_not_null($order->info['cc_number']))  {
$this->cc_card_number_less_middle_digits = substr($order->info['cc_number'], 0, 4) . str_repeat('x', (strlen($order->info['cc_number']) - 8)) . substr($order->info['cc_number'], -4);
?>
				 		   <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b> <?php echo $order->info['payment_method']; ?> (<?php echo $order->info['cc_type']; ?>)<br><b><?php echo ENTRY_PAYMENT_CC_NUMBER; ?></b> <?php echo $this->cc_card_number_less_middle_digits; ?><br><?php echo tep_draw_separator('pixel_trans.gif', '100%', '6'); ?></td>
<?php
 } else {
?>
				 		   <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b> <?php echo $order->info['payment_method']; ?></td>
<?php
 }
?>
<?php // END Better payment mod by BFD ?>
		  </tr>

4. See #3 - I can not duplicate the error. My line 181 is:

 

	$this->cc_card_number_less_middle_digits = substr($order->info['cc_number'], 0, 4) . str_repeat('x', (strlen($order->info['cc_number']) - 8)) . substr($order->info['cc_number'], -4);

 

and its ok for me

 

sorry I could not be of more help

-Dave

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
well, i fixed the U problem, but I'm still getting that error at line 181...yeah, my code looks exactly like yours...

How you fixed the "U" problem ?

Because i have the same error for me it only shows "D" instead of Deutschland.

 

Can you post your fix, please.

Link to comment
Share on other sites

How you fixed the "U" problem ?

Because i have the same error for me it only shows "D" instead of Deutschland.

 

Can you post your fix, please.

Do you also only get the D whwn you okk at the print order in admin?

Link to comment
Share on other sites

In the admin its all ok

 

but in account_history_info.php i allthough have only the "D"

Try this, but backup first.

 

In catalog/includes/functions/general.php: undo the Use The Correct Country Name Value When Formatting Addresses change that appeared in the 20060817 patch.

 

Basically,

$country = tep_output_string_protected($address['country']['title']);

becomes

if ($country == '') $country = tep_output_string_protected($address['country']);

Link to comment
Share on other sites

This may be way out in left field, but it's worht a try.

 

Does anyone know a way to configure the receipts to only include particular items rather than all items. Either by a common attribute, or product id, or anything.

 

I am on a bit of a deadline for this projet so any help will be appreciated.

Link to comment
Share on other sites

This may be way out in left field, but it's worht a try.

 

Does anyone know a way to configure the receipts to only include particular items rather than all items. Either by a common attribute, or product id, or anything.

 

I am on a bit of a deadline for this projet so any help will be appreciated.

 

Could you be any more specific? Example perhaps?

man of a reformed faith.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...