Hi,

First up - thanks for a great little module.... this is nearly spot on as an essential commerce contrib 'must have'.

I was just trying to work out theming customisations. The tpl.php file included in the module gets over ridden as normal when placed in my theme - but only for the 'View printable invoice' link..... if I click on the print link the module template gets used instead - anyone else have this issue?

Also along these lines - what if I need to over ride the css in the module? For now I am happy to use inline styles on the template file - but in the long run it might be good to allow the user to specify the css location outside of the module?

The other issue I was trying to resolve is how to get the additional tax line items to show in the invoice - the same as they show on the checkout or order view pages - any ideas?

I'm guessing these issues will be on the list of to-do's somewhere already, but if not then hope the info helps, and anything else I can do to help test let me know.

Comments

benstallings’s picture

I'd like to echo the necessity of not hard-coding the template and stylesheet locations into the module, because if we change the files inside the module directory they will get overridden when we upgrade the module.

Since some sites use multiple themes, it may not be desirable to ask users to put their customized template and stylesheet files in the theme directory. Perhaps instead there could be a configuration page for the module (or an added option on admin/commerce/config/order) where the default path to the files can be changed to a custom path.

Thanks again for a great module.

benjy’s picture

The issue with the print link is that it looks for an overridden tpl file in your admin theme, not your site theme.

I got around this by having two template files which pulled my actual template in from a module. This also helps you get extra information into the template. From your overridden template file you can call your own theme function passing the order and info variables, add any extra data in your module and then pass it all to your template file.

Not sure about overriding the CSS. I just used inline styles for now.

tars16’s picture

I'm also experiencing the module template file getting loaded when an admin clicks the print link for an order.

I agree that it would be nice to have a way to specify a path from a configuration page for the template to used.

emilorol’s picture

StatusFileSize
new2.65 KB

Hi,

The following patch solve the issue of the admin having a different theme as the default site theme and it also apply the fix if the admin or rule is set to email the invoice after changing the order status. The current patch solve the issue, but will require that you place "commerce-order-invoice-view.tpl.php" in your theme or in a folder call "invoice" or "templates" in your theme. Something similar apply to "commerce_invoice_receipt.css" you can added to the "css" folder of your theme or in a folder call "invoice" inside your theme.

jbrinker’s picture

As a n00b, I'm hoping for a simple answer to this question, but likely wishful thinking. I have multiple forms/products on my website for various events. After registering for an event and choosing "Check" as the payment option, the user is supposed to print their invoice and then mail it with their check to the event coordinator. Since there are multiple events, there are multiple event coordinators, and multiple mailing addresses.

Is there any way to make the invoice specific to the form being submitted? Thanks for the help!

emilorol’s picture

@jbrinker,

Out of the top of my head, I think that if the coordination address is part of the product (event) and you can simple added thru the product manage display > invoice. If you want to place it in an specific place on the template then you can edit the template file and use something like:

<div class="mail-to">
<?php print $order->coordinator_name; ?>
<?php print $order->coordinator_address; ?>
</div>
loze’s picture

thanks for that patch @emilacosta

I had to apply it manually against the latest dev, but it mostly worked. Only thing it was missing was that the css was still using the module path in the print/screen version only the email version was being overridden.

attached is a new patch.

loze’s picture

Status: Active » Needs review
leo pitt’s picture

Status: Needs review » Needs work

Thanks for working on this. The patch almost works for me.

It assumes that the order receipt template is stored in either my-theme/templates/ or my-theme/invoice/

I think this is an unsafe assumption, since many themes simply hold their template files in the theme root directory, and themers may choose to have some other folder structure.

Perhaps use file_scan_directory to recursively parse the theme directory instead?

flosuter’s picture

So, I looked kinda long into this, but wasn't satisfied with any presented solutions. Finally I found hook_admin_paths_alter.

With a small function in a custom module you can change the two paths for the invoice views to non-admin. This could also be implemented in "Commerce Invoice Receipt" directly.

/**
 * Implements hook_admin_paths_alter().
 */
function YOURCUSTOMMODULE_admin_paths_alter(&$paths) {
  // Treat the invoice view paths as a non-administrative pages.
  $paths['admin/commerce/orders/*/view/print'] = FALSE;
  $paths['admin/commerce/orders/*/view/mail'] = FALSE;
}
ar-jan’s picture

I just noticed this was already commited back last May, and is now included in the last release (1.4). Can this be considered fixed or is followup to the later comments needed? (I've actually implemented the approach in #10 in a custom module).

daglees’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)

  • Commit bddc186 on 7.x-1.x, 7.x-2.x by Daglees:
    Issue #1363752 by emilacosta, loze, Daglees: Theming invoice templates
    
alexdezark’s picture

Hi there,

does anyone know a serious solution to send email when a drupal commerce order is finished ?
I mean a non-dev module with a working librairie, not emogrifier witch is unmaitained, buggy and need a patch to be detected by drupal (https://www.drupal.org/node/2195043).

If possible, a short tutorial will be appreciate too.

griz’s picture

I'm finding that commerce_message works perfectly.
Enable mailsystem and mimemail, then use mailsystem to select your the theme with which you would to process outgoing messages. In that theme's css folder, add some stuff to mail.css or create it if your theme doesn't already have it.
Go to 'Structure' -> 'Message types' to change the email text. Be sure to add any html tags you use to the appropriate Text Format.
If you want emails to be sent when order statuses are updated, add the Send Message with Message Notify action to the associated Rule; by default the other Rules create a message entity but don't send an email.

fhdrupal’s picture

I can override both the tpl file and css. I can add some new messages to it, but the problem I am getting is, I cannot add any css class to tags, without which using custom template I suppose is very limited or useless. whenever I add css class to any tag, during rendering process the classes are removed.
How can I solve this problem?????

Thanks,

fhdrupal’s picture

Just to let you all know I am too much exited to have found solution to my problem.

It has something to do with "Emogrifier" option, if you have this enabled for a template, module or file. I found it in "Configuration > Content authoring > Text formats" and for "Print Order" module I visited " Configuration > Content authoring > Text formats > Print Orders".

Emogrifier converts all stylesheet rules to inline style attribute during the rendering process. So if a class disappears from a tag you created don't worry, whatever style you write, it will be converted to inline exactly how and where you wanted.
You can disable it, but its good for printing that's why I didn't, because now I know what it does.

khan2ims’s picture

I am not able to get Emogrifier to work even though the status page its activated.