Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've created a separate menu entry for our purpose on commerce_billy_pdf (currently as custom extension):
$items['admin/commerce/orders/%commerce_order/pdf-invoice'] = array(
'title' => 'Invoice (PDF)',
'page callback' => 'commerce_billy_pdf',
'page arguments' => array(3),
'access callback' => 'commerce_billy_pdf_view_access',
'access arguments' => array(3),
'type' => MENU_LOCAL_TASK,
'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
'weight' => 10,
'file' => 'commerce_billy_pdf.module',
'file path' => drupal_get_path('module', 'commerce_billy_pdf') . '/',
);
If you like it, that would be a nice upgrade for commerce_billy_pdf to easier access the pdf invoice by default. I'm sorry that I have not created a patch directly, but my current environment does not allow that ;)
Comment | File | Size | Author |
---|---|---|---|
#13 | add_an_invoice_pdf_tab-2107513-13.patch | 1.2 KB | mglaman |
#8 | commerce_billy-pdftab-2107513-8.patch | 1.35 KB | discipolo |
Comments
Comment #1
AnybodyOn the clients (user) order page something like this could make sense, but perhaps it is too hard coded or should have a separate permission "Access Invoice PDF download link":
But that snippet doesn't work yet. What's your opinion in general about this?
Comment #2
fonant CreditAttribution: fonant commentedI also added a menu tab to the order page for administrators to easily view/download the invoice. Your menu code is a bit more robust than mine, so I've borrowed it!
Adds an "Invoice (PDF)" tab to orders that have invoices. The tab doesn't appear for orders that don't have invoices.
Now I wonder if we need to display invoices for orders that are in other states, such as "Processing" and "Completed" too, or whether it's safer to store the PDF files somewhere else...
Comment #3
TheoRichel CreditAttribution: TheoRichel commentedThis is very useful......if only I knew where I should paste this piece of code. Please help!
Comment #4
fonant CreditAttribution: fonant commented@ThoeRichel - Ideally you need to create a custom module to contain this code in a function that implements hook_menu(). But so long as you're careful with future updates, you can paste it into the function commerce_billy_pdf_menu() in commerce_billy_pdf.module. It should be clear where it goes with the other menu item definitions.
Comment #5
TheoRichel CreditAttribution: TheoRichel commentedThanks very much!
Comment #6
lsolesen CreditAttribution: lsolesen commented@Anybody Are you up for creating a patch for Commerce Billy as this seems as a clever idea?
Comment #7
discipolo CreditAttribution: discipolo commentedComment #8
discipolo CreditAttribution: discipolo commentedComment #9
lsolesen CreditAttribution: lsolesen commentedThis works for me. Only question is whether we need to do a clear cache to get it to show right away?
Comment #10
AnybodyWell the clear cache is not required I think. It's only required if you patch the module which is already installed. On fresh install Drupal clears the menu cache after enabling a new module.
So I think you could add this to the next .dev version?
Comment #11
lsolesen CreditAttribution: lsolesen commentedThough, it might also be useful to have this tab on: user/5703/orders/21 so the user can access the pdf when logged into the system?
Comment #12
lsolesen CreditAttribution: lsolesen commentedActually, this menu item is created in the wrong module. Should be in commerce_billy_pdf instead.
Comment #13
mglamanRe-roll with menu path in proper module.
Comment #14
doxigo CreditAttribution: doxigo commentedOkay thank you guys for the patches, I used mglaman patch to add the Invoice Tab, but how about a tab or button for the user? so he can access the invoice while viewing his order?
Comment #15
fugazi CreditAttribution: fugazi commented#14 I also find a good thing. So the customer can download the bill itself.
Comment #16
mglamanThat's outside of the scope of the patch, would need to investigate commerce_billy_pdf_view_access(), which takes a commerce order as the access argument (as far as I can tell.)
First step would to get this fixed, then rework invoice permissions.
Comment #17
Joe HuggansI am unable to view the invoice, I get an Access Denied message when navigating to the url order/1234/pdf-invoice, even when using admin role
Comment #18
mglamanjoeuk, the patch in #13 doesn't support that - only from the admin.
Comment #19
Joe HuggansHi mglaman, yes I am using admin user but I still get Access Denied.
Comment #20
Joe HuggansHowever I did only create separate module, I will try patch later and report back... But even still it should not be behaving like this
Comment #21
Joe HuggansWhere should the tab be showing up to download the PDF invoice for the order, because I again don't see anything.
Also I am getting access denied message when navigating to www.mysite.com/invoice-pdf/[order-number]
Comment #22
silkogelman CreditAttribution: silkogelman commentedResults patch #13:
Both appear only if the order has status 'invoiced'
I also tested in combination with multiple order statuses that have PDF download permission #2108335: Allow PDFs to be downloaded from other order states than invoiced.
Result is perfect: the 'invoice (pdf)' only appears for orders that have statusses that have 'PDF download permission'.
Tested & works with
Untested:
If #16 is correct, than this current issue seems to be fixed and we can create the ability for customers to download their order as PDF in another issue.
Comment #23
Anonymous (not verified) CreditAttribution: Anonymous commented+1
Comment #24
klausiCommitted, thanks!