By cwrighta70 on
Hello, all!
I have created a new invoice template by copying the current uc-order-admin.tpl.php file and renaming it uc-order-custom.tpl.php. This file is placed in ubercart/uc_order/templates. I have also copied this file to sites/all/themes/MYTHEME/invoice (which also contains uc-order-customer.tpl.php and uc-order.tpl.php). Unfortunately, I do not see my new template as an option in the Conditional Actions? I only see admin and customer.
Can someone please help me with this? I've been reading through this link: http://www.ubercart.org/docs/developer/17385/changing_invoice_templates_...
...but cannot seem to find an answer.
Thanks!
Chris
Comments
Hopefully I'm not breaking
Hopefully I'm not breaking forum rules, but I'm bumping this thread so that it gets seen (as it is now on the 3rd page).
You need hook_uc_invoice_templates()
You have to implement hook_uc_invoice_templates()
/**
* Implementation of hook_uc_invoice_templates().
*/
function your_module_uc_invoice_templates() {
return array('customer-your_template');
}
I Know you wrote on 1. Feb but i hope this helps you :)
tobi
Thanks tobi. We found the
Thanks tobi. We found the same thing, except we just added our new template to the current list:
So, for those of you searching for an answer to this, here is your answer! First, the array shown in the code sample above is ONLY set during the installation process. You must edit the sites/all/modules/ubercart/uc_order/uc_order.module file. Search for the function shown in the above code sample, and add the name of your template to this array.
Please note that your template name must be using this naming convention: uc_order-templateName.tpl.php, and the name that you will add to the array is only templateName.
Hope this solves your problem as well.
Chris
And ironically placing this
And ironically placing this in your theme folder doesn't actually work. You totally have to place this in the ubercart folder which is well annoying and pretty un-Drupal...
The correct implementation
The correct implementation for this is something like
where your template name is uc_order-your_template.tpl.php and is placed in uc_order/templates
If you want to keep your
If you want to keep your template out of Ubercart's directories (this makes it easier to update Ubercart later) try:
This assumes you have a templates/ directory in your module's directory.
Why so complicated now?
In Drupal 6 ubercart I could just put uc-order--customer.tpl.php in my theme templates folder and it just worked.
Now we need to make a custom module to override the invoice?
very helpful - thanks
very helpful - thanks
Another solution
Another solution which is a variation to the above.
Create a small module and then alter the theme registry, this works for both the customer invoice and admin invoice (which typically can be quite troublesome).
This forces Ubercart to use your customised template for both customer & admin. After enabling the module, clear the theme registry (drush cc theme-registry or drush cc all).
Simple module structure:
tax_invoice/tax_invoice.info
tax_invoice/tax_invoice.module
tax_invoice/templates/uc-order.tpl.php
tax_invoice/tax_invoice.module
tax_invoice/templates/uc-order.tpl.php*
* This is your customised invoice template.
Agileware are a team of local Drupal developers in Australia, https://agileware.com.au
Agileware support and host Drupal, CiviCRM and WordPress websites.
Contact Agileware today at https://agileware.com.au/contact
I put together a module that
I put together a module that makes this process a lot easier for Ubercart 3 / Drupal 7. It's currently at http://drupal.org/sandbox/Z-TwistBooks/1778488.
no .info file
hello DanZ
Thanks for your module! It sounds very promising and god send for a newbie like me. I tried installing the snapshot tar.gz file from 8 days ago but Drupal doesnt allow me to install it cause it does not contain any .info file. Any guidance is appreciated.
Thanks,
PJ
It does contain an info file.
It does contain an info file. Did you name the extract directory uc_invoice_templates?
Also, please problems (issues) on the project page, so I can find them more easily!
Finally, this module needs more external testing. Once you get it installed, please report if it works or not.
Better version
A non-sandbox version of the module is now available at http://drupal.org/project/uc_register_invoice. It should be easier to install.
--
www.ztwistbooks.com. Math books that are actually fun.
For all you Googlers out
For all you Googlers out there, the solutions for Drupal 7 are completely documented at http://drupal.org/node/1867700.
--
www.ztwistbooks.com. Math books that are actually fun.