Closed (won't fix)
Project:
Commerce Billy
Version:
7.x-1.0
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Apr 2014 at 23:55 UTC
Updated:
19 Apr 2020 at 23:52 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
michfuer commentedOops, forgot to mention this is in regards to commerce_billy_pdf module, and creating multiple pdf templates.
Here's a patch that accomplishes this by defining two hooks:
A new child menu item is created for each template at admin/commerce/config/billy-invoice/pdf
Comment #2
Devaraj commentedCan you please elaborate how to implement this, i have just applied the patch and lost the old configurations and sees no difference in the config page.
Comment #3
roball commentedDevaraj, did you apply the patch from #1 to a Commerce Billy installation on a production site, i.e. into an environment that already created real PDF invoices for your customers? If so, were you able to continue the production environment without any drawbacks; i.e. did your site continue to create the PDF invoices as before applying the patch?
Comment #4
roball commentedThe attached patch can be safely applied to an existing installation of Commerce Billy 7.x-1.0-beta2 or 7.x-1.0-beta2+1-dev. Run Drupal's update script (
update.php) after applying the patch! No existing configuration will be deleted or changed. The patch also adds a complete documentation on how to incorporate multiple PDF templates, and implements a clean uninstaller.Comment #5
roball commentedAttached is the re-rolled patch against the freshly released 7.x-1.0 or the current development snapshot (7.x-1.0+1-dev).
Comment #6
roball commentedNobody interested in this useful feature addition?
Comment #7
rrrhal commentedI tried it out - think it could be very useful. Thanks for your efforts. I set up a pair of hook functions to add a second PDF Settings Page. This worked as expected.
Comment #8
roball commentedThanks for your positive review. Since you have confirmed that the patch is working, please change this issue's status accordingly. This may increase the chance that the module maintainers would commit it.
Comment #9
lunazoid commentedI had a case where the store owner wanted to send different invoices based on whether the customer was a first-time buyer or a repeat customer, and I was able to use #5 to handle that easy enough! However, I hit a snag with commerce_billy_mail trying to generate the template in commerce_billy_mail_pdf_prepare. Essentially, it was passing a single argument to commerce_billy_pdf_html (the $order object,) but after applying the patch, commerce_billy_pdf_html required both $order and $template_name. I was able to adapt commerce_billy_mail_pdf_prepare to make it work fine, but I'm wondering if the answer should be to change the way commerce_billy_pdf_html has been modified. Instead of getting the template name before calling commerce_billy_pdf_html, it could invoke the hooks to get the template based on the order itself. I'm thinking this might make sense, as it is getting an array of orders, and we might need to check each order to determine its appropriate template. It would also make it play nicely with any other modules that are calling commerce_billy_pdf_html.
I'm happy to make the patch, but I wanted to get some thoughts before doing this. Otherwise, I can submit a patch for commerce_billy_mail so it will integrate with this.
Comment #10
roball commented@lunazoid: thank you for your review! I was not yet using the Commerce Billy Mail module, so I did not test my patch in conjugation with that module.
If you could rewrite the patch to restore
function commerce_billy_pdf_html()not to require$template_nameas second argument, that will of course be fine, so Commerce Billy Mail plays nicely with Commerce Billy as it is.Comment #11
roball commentedComment #12
lunazoid commentedHere is the modified version of the patch that I am using, along with an interdiff with the patch in #5. The only change is that it moves the functions for getting the template names into the orders loop, keeping the parameters for commerce_billy_pdf_html the same.
Comment #13
roball commentedThank you lunazoid for updating the patch. Attached there is a clean up, with little changes remaining from my previous patch.
Comment #14
lunazoid commented@roball: That looks good! I'll go ahead and mark this as RTBC, as I am currently using this feature.
Comment #15
klausiI think this use case is not common enough to incorporate it into this module. Instead, you can swap out commerce_billy_pdf_commerce_order_view() with hook_module_implements_alter() and/or replace the page callback commerce_billy_pdf() with hook_menu_alter() in your custom module. You can also introduce your own menu callbacks there, that should also work. You can even publish this custom module on drupal.org as an extension to this module - let me know when you do, happy to link it from the project page :-)
Comment #16
mp commentedhi
@klausi - this case is common for every shopowner in europe where you have both P2B and B2B buyers, because B2B don´t pay VAT and you need to write a different text into the bill
i would love to have this feature as standard in the module - please add it! :)
Comment #17
firfin commentedI woudl also like to see this incorporated in to the module. Very useful. Or essential even of you run multiple stores from one backend.
Also #16 indeed.
Will test (and probably re-roll) this soon!
Comment #18
firfin commentedWhile I still believe it would be nice to have some API functionality for this. I do not have the time to follow up on this, especially since it will probably be fruitless without maintainer support.
I did however solve my problem in another way. By setting different themes for the different domains (frontends for commerce) / shops and then logging into a specific domain it is possible to 'choose' the template used, by selecting which domain ( and thus theme) you login. Bit unwieldy, but tit seems to work for now. Maybe I will get back to this at some point (note to self : tr : PDF template choice billy)