Post by rogery » Wed Jan 18, 2012 8:59 pm

v1.4.9.4

Can anyone help. I want to add a button to the Checkout Confirmation page to generate and print the Invoice (the same as would be printed from the Admin Order Form).

Thanks.
Last edited by i2Paq on Tue Jan 24, 2012 7:36 pm, edited 1 time in total.
Reason: Title adjusted

New member

Posts

Joined
Wed May 26, 2010 5:55 pm

Post by Qphoria » Wed Jan 18, 2012 11:27 pm

I think a better idea would be to have the normal success page show the full invoice and offer a print button. Something OpenCart has needed for a while

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by straightlight » Tue Jan 24, 2012 10:28 am

Qphoria wrote:I think a better idea would be to have the normal success page show the full invoice and offer a print button. Something OpenCart has needed for a while
Done. XML file ready and also the additional invoice template file: order_invoice.tpl file to be uploaded in the catalog/view/theme/<your_custom_template/template/common folder. Since TPL files can't be uploaded on the forum, here's the code:

Code: Select all

<?php echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php echo $direction; ?>" lang="<?php echo $language; ?>" xml:lang="<?php echo $language; ?>">
<head>
<title><?php echo $title; ?></title>
<base href="<?php echo $base; ?>" />
<link rel="stylesheet" type="text/css" href="view/theme/default/stylesheet/invoice.css" />
</head>
<body>
<?php foreach ($orders as $order) { ?>
<div style="page-break-after: always;">
  <h1><?php echo $text_invoice; ?></h1>
  <table class="store">
    <tr>
      <td><?php echo $order['store_name']; ?><br />
        <?php echo $order['store_address']; ?><br />
        <?php echo $text_telephone; ?> <?php echo $order['store_telephone']; ?><br />
        <?php if ($order['store_fax']) { ?>
        <?php echo $text_fax; ?> <?php echo $order['store_fax']; ?><br />
        <?php } ?>
        <?php echo $order['store_email']; ?><br />
        <?php echo $order['store_url']; ?></td>
      <td align="right" valign="top"><table>
          <tr>
            <td><b><?php echo $text_date_added; ?></b></td>
            <td><?php echo $order['date_added']; ?></td>
          </tr>
          <?php if ($order['invoice_no']) { ?>
          <tr>
            <td><b><?php echo $text_invoice_no; ?></b></td>
            <td><?php echo $order['invoice_no']; ?></td>
          </tr>
          <?php } ?>
          <tr>
            <td><b><?php echo $text_order_id; ?></b></td>
            <td><?php echo $order['order_id']; ?></td>
          </tr>
        </table></td>
    </tr>
  </table>
  <table class="address">
    <tr class="heading">
      <td width="50%"><b><?php echo $text_to; ?></b></td>
      <td width="50%"><b><?php echo $text_ship_to; ?></b></td>
    </tr>
    <tr>
      <td><?php echo $order['payment_address']; ?><br/>
        <?php echo $order['email']; ?><br/>
        <?php echo $order['telephone']; ?></td>
      <td><?php echo $order['shipping_address']; ?></td>
    </tr>
  </table>
  <table class="product">
    <tr class="heading">
      <td><b><?php echo $column_product; ?></b></td>
      <td><b><?php echo $column_model; ?></b></td>
      <td align="right"><b><?php echo $column_quantity; ?></b></td>
      <td align="right"><b><?php echo $column_price; ?></b></td>
      <td align="right"><b><?php echo $column_total; ?></b></td>
    </tr>
    <?php foreach ($order['product'] as $product) { ?>
    <tr>
      <td><?php echo $product['name']; ?>
        <?php foreach ($product['option'] as $option) { ?>
        <br />
        &nbsp;<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
        <?php } ?></td>
      <td><?php echo $product['model']; ?></td>
      <td align="right"><?php echo $product['quantity']; ?></td>
      <td align="right"><?php echo $product['price']; ?></td>
      <td align="right"><?php echo $product['total']; ?></td>
    </tr>
    <?php } ?>
    <?php foreach ($order['total'] as $total) { ?>
    <tr>
      <td align="right" colspan="4"><b><?php echo $total['title']; ?>:</b></td>
      <td align="right"><?php echo $total['text']; ?></td>
    </tr>
    <?php } ?>
  </table>
  <?php if ($order['comment']) { ?>
  <table class="comment">
    <tr class="heading">
      <td><b><?php echo $column_comment; ?></b></td>
    </tr>
    <tr>
      <td><?php echo $order['comment']; ?></td>
    </tr>
  </table>
  <?php } ?>
</div>
<?php } ?>
</body>
</html>
Update: catalog/view/theme/<your_custom_template>/stylesheet/invoice.css file.

Code: Select all

/*
 * jQuery Nivo Slider v2.5.2
 * http://nivo.dev7studios.com
 *
 * Copyright 2011, Gilbert Pellegrom
 * Free to use and abuse under the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * March 2010
 */
/* The Nivo Slider styles */
.nivoSlider {
	position: relative;
}
.nivoSlider img {
	position:absolute;
	top:0px;
	left:0px;
	display: none;
}
/* If an image is wrapped in a link */
.nivoSlider a.nivo-imageLink {
	position:absolute;
	top:0px;
	left:0px;
	width:100%;
	height:100%;
	border:0;
	padding:0;
	margin:0;
	z-index:6;
	display:none;
}
/* The slices and boxes in the Slider */
.nivo-slice {
	display:block;
	position:absolute;
	z-index:5;
	height:100%;
}
.nivo-box {
	display:block;
	position:absolute;
	z-index:5;
}
/* Caption styles */
.nivo-caption {
	position:absolute;
	left:0px;
	bottom:0px;
	background:#000;
	color:#fff;
	opacity:0.8; /* Overridden by captionOpacity setting */
	width:100%;
	z-index:8;
}
.nivo-caption p {
	padding:5px;
	margin:0;
}
.nivo-caption a {
	display:inline !important;
}
.nivo-html-caption {
	display:none;
}
/* Direction nav styles (e.g. Next & Prev) */
.nivo-directionNav a {
	position:absolute;
	top:45%;
	z-index:9;
	cursor:pointer;
}
.nivo-prevNav {
	left:0px;
}
.nivo-nextNav {
	right:0px;
}
/* Control nav styles (e.g. 1,2,3...) */
.nivo-controlNav a {
	position:relative;
	z-index:9;
	cursor:pointer;
}
.nivo-controlNav a.active {
	font-weight:bold;
}
/* slider theme */
.slideshow {
	margin-bottom: 20px;
}
.slideshow a {
	border: 0;
	display: block;
}
.nivo-controlNav {
	position: absolute;
	right: 10px;
	bottom: 5px;
	text-align: center;
	height: 22px;
	z-index: 99;
}
.nivo-controlNav a {
	vertical-align: top;
	display: block;
	width: 22px;
	height: 22px;
	background: url('../image/bullets.png') no-repeat;
	text-indent:-9999px;
	border:0;
	margin-right:3px;
	float:left;
}
.nivo-controlNav a.active {
	background-position:0 -22px;
}
.nivo-directionNav a {
	display:block;
	width:30px;
	height:30px;
	background:url('../image/arrows.png') no-repeat;
	text-indent:-9999px;
	border:0;
}
a.nivo-nextNav {
	background-position:-30px 0;
	right:15px;
}
a.nivo-prevNav {
	left:15px;
}
.nivo-caption {
	text-shadow:none;
	font-family: Helvetica, Arial, sans-serif;
}
.nivo-caption a {
	color:#efe9d1;
	text-decoration:underline;
}
An expiry time has also been implemented to 15 minutes of inactivity regarding the invoice after the original order ID has been unset from the success page. Customers may now print their invoice during that time upon successful orders.

Attachments

Last edited by straightlight on Tue Jan 24, 2012 9:21 pm, edited 1 time in total.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Tue Jan 24, 2012 10:42 am

TPL file code fixed above. A small typo.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by jty » Tue Jan 24, 2012 3:57 pm

Hi straightlight, I'm having a small problem with your mod regarding totals.
Firstly, I changed :

Code: Select all

<search position="after" index="6"><![CDATA[}]]></search>
to

Code: Select all

<search position="after" offset="1"><![CDATA[$this->response->setOutput($this->render());]]></search>
as searching on the one char } was upsetting another of my mods.

Now I'm stuck on

Code: Select all

$total_data = $this->model_checkout_order->getOrderTotals($order_id[0]);
I can't find getOrderTotals in model/checkout/order
I found getOrderTotals in model/account/order
and I got somthing to work by using

Code: Select all

$this->load->model('account/order');
total_data = $this->model_account_order->getOrderTotals($order_id[0]);
now I'm all confused. I also need to fix the css

BTW - thanks for all the time you put into these forums. I've noticed you're in here helping a lot. Thank-you

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by jty » Tue Jan 24, 2012 4:34 pm

With the stylesheet, I took a copy of invoice.css from admin and stuck it in catalog
and changed

Code: Select all

<link rel="stylesheet" type="text/css" href="view/theme/default/stylesheet/invoice.css" />
to

Code: Select all

<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/invoice.css" />
thank-you, thank-you, thank-you

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by straightlight » Tue Jan 24, 2012 9:22 pm

XML file updated. As for your offset issue and that you already have modified entries in the file, that is not something on my end so this won't be updated. As for the invoice CSS file and the order totals model, it has now been updated. Make sure to modify the images folders within the CSS at your disposal.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by bfreemanfl » Wed Feb 29, 2012 9:29 am

I am assuming I am doing something wrong because I see no change at all after following these steps.

1. I copied the code and created "order_invoice.tpl" with it
2. I uploaded it to : catalog/view/theme/default/template/common folder
3. I downloaded the XML file, and uploaded it to : catalog/view/theme/default/template/common folder
4. I copied the code for the CSS and "created" catalog/view/theme/default/stylesheet/invoice.css

After doing these steps, I literally se NO difference. I'm assuming there is a step that I have to do that's not listed??

Newbie

Posts

Joined
Fri Dec 10, 2010 12:46 pm

Post by straightlight » Wed Feb 29, 2012 5:05 pm

3. I downloaded the XML file, and uploaded it to : catalog/view/theme/default/template/common folder
There are no such case of uploading an XML file into that folder. All XML files goes to the vqmod/xml folder as you must have VQMod installed to see the results.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by bfreemanfl » Thu Mar 01, 2012 3:35 am

Ahhhhhhhhhhhhhhh

I have VQMod installed...I wondered how teh XML was going to be pulled in by simply plopping it there. I'll try to put it inside that folder tonight and will report back.

Thanks for the fast reply!

Newbie

Posts

Joined
Fri Dec 10, 2010 12:46 pm

Post by bfreemanfl » Thu Mar 01, 2012 3:57 am

Ok....so I installed VQMod last night...and I just uploaded the XML file into the VQMod/XML folder.

And still nothing is being displayed after order success (As far as being able to view the invoice / print button). Just normal.

I'm REALLY new at this sort of stuff so please bare with me.

Do I need to run or add anything else besides just placing the xml inside the vqmod/xml folder (and other changes I haev already done and listed above)???

I looked in the vqmod/vqcache folder, and I do see
- vq-catalog_controller_checkout_success.php
- vq-catalog_language_english_checkout_success.php
- vq-catalog_model_checkout_order.php

as well as a few other files, so it looks like it's doing something.

I just don't see anything other than the usually successful message after checkout.

I'm testing it with a fresh install (you can click through an order as I have guest enabled and COD for payment).
http://steinermilitaryscopes.com/

Another note: I installed VQMod 1.2.3 (if it matters).

Newbie

Posts

Joined
Fri Dec 10, 2010 12:46 pm

Post by tobychin » Tue Mar 20, 2012 3:22 am

I was really hoping to find something like this and straightlight, you did it again! I am having one problem, though. I keep getting a "SyntaxError: JSON.parse: unexpected character" error after uploading the XML into my test server.

Any ideas? Thanks in advance!

- Toby
"The only way to get to the top is to get off your bottom." - Fortune Cookie


New member

Posts

Joined
Tue Jul 12, 2011 12:03 am
Location - Warsaw, Indiana

Post by straightlight » Tue Mar 20, 2012 4:39 am

Hi tobychin,

if you rename the XML extension to something else and re-test this behavior from checkout, can you define from there if the JSON error keeps showing ?

AFAIK, my XML file does not make any requests to JSON.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by tobychin » Tue Mar 20, 2012 4:46 am

Well, I moved the file out of the xml folder (leaving the tpl and css files where they were) and retested. Problem disappears.

To be a bit more specific, I get the error on the checkout page, when I try to confirm my payment type (step 5).

- Toby
"The only way to get to the top is to get off your bottom." - Fortune Cookie


New member

Posts

Joined
Tue Jul 12, 2011 12:03 am
Location - Warsaw, Indiana

Post by straightlight » Tue Mar 20, 2012 5:33 am

Are you using any contributions with your test server ? My XML file should only show the invoice upon successful orders.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by tobychin » Tue Mar 20, 2012 5:53 am

Not sure I know what you mean by contributions... I'm not getting the invoice before placing the order... Here's what I'm doing:

On my test server (which has several modifications), I enabled the COD payment option. Then, I selected an item at random and added it to my cart. After going through almost the entire checkout process, it throws the JSON error at me in a pop up box. If I go straight to "<site>/index.php?route=checkout/success", it has the "Print Invoice" button successfully displayed. However, since I don't have an order in the last 15 minutes, clicking on it just takes me to the home page.

Hope that helps clarify. Thanks for your help again, straightlight.

- Toby
"The only way to get to the top is to get off your bottom." - Fortune Cookie


New member

Posts

Joined
Tue Jul 12, 2011 12:03 am
Location - Warsaw, Indiana

Post by straightlight » Tue Mar 20, 2012 6:43 am

On my test server (which has several modifications)
So, yes, you do have contributions installed.

As for the 15 minutes idleing, it will indeed forward back to the home page and as explained on my original post regarding security issues when leaving idled orders since the success page is not under SSL by default.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by scanreg » Tue Mar 20, 2012 9:34 pm

Qphoria wrote:I think a better idea would be to have the normal success page show the full invoice and offer a print button. Something OpenCart has needed for a while
:) :)

Active Member

Posts

Joined
Thu May 06, 2010 12:15 am

Post by straightlight » Tue Mar 20, 2012 9:37 pm

@scanreg:

This is what my XML file already does.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by stonehinged » Mon Apr 09, 2012 9:45 pm

Does this also return the order tax and order shipping to the success page?

STONEHINGED
Handcrafted, Semi-Precious Jewelry
http://www.stonehinged.com/


User avatar
Active Member

Posts

Joined
Wed Aug 18, 2010 9:10 am
Location - US
Who is online

Users browsing this forum: No registered users and 128 guests