0

Using Magento 1.9.0.1

When i am logged in as customer and placed an order, upon /checkout/onepage/success/ there is a line of text saying: Click here to print a copy of your order confirmation.

When clicking that link, it shows a (unstyled) page with the order details : /sales/order/print/order_id/3/ AND the "popup" for printing the order.

This also works the same when going in my account and viewing orders...

1) how can i prevent the contents showing on page (unstyled) so it will only show the print popup

2) what file would i need to edit to remove that print option all together from the page after placing the order: /checkout/onepage/success/

3) i also want to show that page as 1 column page would that need to be done on that same page?

Thought i might ask all these questions in 1 post as they are all closely related.

Thanks

Carlo

0
  1. Not sure what you mean, here. Are you referring the Google Chrome "print dialog?" - not much you can do about that one. As for preventing the printable order contents from appearing in a popup/new tab, you'd can take one approach that comes to mind.

Print Dialog Override, AJAX Method

Extend app/design/frontend/base/default/template/checkout/success.phtml -- may be different depending on your theme. Change this line:

<?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>

To this:

<?php echo $this->__('Click <a href="javascript:;" onclick="new Ajax.Request('%s', {onSuccess:function(){ ... }});">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>

The above is more like pseudo-code, and I do not advise to write it like that, but you can get the idea that you'd make an AJAX request for the printable contents, and upon its return, you can write it directly to the success page in a modal or something nice -- then prompt to print.

  1. See the template referenced in #1.

  2. "That page" -- The checkout success page? See below.

Changing the Checkout Success Template

Extend the app/design/frontend/base/default/layout/checkout.xml -- or else add the following to your local.xml

<checkout_onepage_success translate="label">
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
</checkout_onepage_success>
  • Hi thanks for this... what i meant was ... when you submit your order i get an order confirmation on screen, hardly any styling etc... and a print dialog on top of that... I'd like to get rid of that print dialog and just show a thank you page. (the order is mailed to client anyway) – carlo Nov 26 '14 at 11:35
  • The thank you page should be shown at first. The content, as I recall in most stock Magento installations, will contain a link to print the order. If you want to remove the option to print, then strip the code out of the template shown at the top of my answer. If you want to let them see the order confirmation, but not prompt to print, then extend app/design/frontend/base/default/templates/sales/order/print.phtml and remove the end which calls for window.print() – Rick Buczynski Nov 26 '14 at 18:13
  • Thanks vBuck, indeed thank you page shows first (as it should), the order confirmation is than send to the customer... so i do not want to show it i guess... thanks for the hint what line to remove if i do not want to show print... but what if i do want to show print but not show the order confirmation(same goes for when someone wants to print an order or invoice from their account... when clicking print, besides getting the print dialog it also shows the order in an unformatted screen at the same time... that i want to get rid of. – carlo Nov 27 '14 at 20:21
  • Well ... what you're asking for is not practically possible. In web browsers, a document to be printed must first be visible in a window. At least this is how I've always seen it work. Maybe the closest you can get is to let them download a PDF version, but to implement that is outside the scope of this question. To be honest, I don't understand why this is such a hindrance for you in the first place. It looks like I've answered questions 2 and 3 for you. If you need further help with question 1, you should ask a new question before this thread grows too long! – Rick Buczynski Nov 27 '14 at 23:54
  • P.S. - you could also look into this: stackoverflow.com/questions/18325025/… and do some trickery using my solution #1 above that renders the print content in a modal on the page when "print is clicked" - then, if browser support lets you listen for onafterprint, you could use that to destroy the modal so that the visitor only really sees it during the system print preview; however, this should not be considered a best case solution. – Rick Buczynski Nov 27 '14 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.