Hi,
Just wondering if there is a way to either use difference templates when emailing an invoice via rules, or alternatively make some elements of an invoice conditional based on who the invoice is going to.
In my scenario upon placing an order an email gets sent to the customer, with full invoice and a short thank you note above it in the email, a copy of the invoice also goes to the accounts department, and one to the warehouse to handle dispatch. It would be great if I could customise what gets sent to each.
I noticed in function commerce_invoice_receipt_mail there is a switch on $key with a single case ('invoice'), and wondered if that was the beginnings of handling multiple cases.
Cheers,
Sam
Comment | File | Size | Author |
---|---|---|---|
#4 | commerce_invoice_receipt_multiple_templates-2316221-4.patch | 25.13 KB | jlockhart |
#2 | commerce_invoice_receipt_multiple_templates-2316221-2.patch | 7.86 KB | mstrelan |
Comments
Comment #1
mstrelan CreditAttribution: mstrelan commentedI believe this exists in Ubercart, or it at least existed when I last used it in Drupal 6. Would be great to have this in Commerce. I believe it would be as simple as:
commerce_invoice_receipt_theme()
commerce_invoice_receipt_rules_action_info()
. Add an option to choose the template to use.commerce_invoice_receipt_action_mail()
to detect which template was chosen. Include that as the second argument todrupal_mail()
, eg invoice_admin.commerce_invoice_receipt_mail()
to invoke the new theme hook.In that time I could have written a patch ...
Comment #2
mstrelan CreditAttribution: mstrelan commentedHere's a first attempt at a patch. Currently if you override the template file in your theme directory you would need to override both template files. Should be easy to fix in the hook_theme() implementation. Also, I was previously able to put my template in a subdirectory of my theme but now I cannot for some reason. Have not really looked in to that.
Comment #3
aramboyajyan CreditAttribution: aramboyajyan commentedCould you please create a patch against the latest dev branch? Thanks!
Comment #4
jlockhartThis was exactly what we were looking for. I've rerolled the patch to work with 7.x-2.x-dev and I updated the find the templates code so that it searches for both the customer and admin templates in the front end theme. I have my templates within /templates and its picking them both up.
Thanks.
Comment #5
joel_osc CreditAttribution: joel_osc at OpenPlus commentedThanks @jlockhart for the nice work on the patch, we need this functionality as well. I did notice the patch in #4 breaks my site because function commerce_invoice_receipt_rules_action_info() is now declared twice.
I think the code added to commerce_invoice_receipt.module needs to be moved to commerce_invoice_receipt.rules.inc.