Closed SimPru closed 9 years ago
As mentioned in the readme you have to enable the store pdf feature. Put this into an initializer:
Spree::PrintInvoice::Config.set(store_pdf: true)
Spree::PrintInvoice::Config.set(storage_path: 'pdfs/orders') # Default: tmp/order_prints
The pdf is then automatically created when the order reaches the complete
state.
Hope this helps
I have of course enabled pdf storing in the settings according to the readme, but for me the pdfs are not generated automatically. The pdfs are generated only when clicking on "Print Invoice" in the admin tool.
Automatically creating when reaching the complete state would be exactly what I need...
Thank you once more!
/c @mamhoff
Hi @SimPru ! You can create an invoice by calling
@order.invoice.pdf # for very recent versions of `spree_print_invoice`
or
@order.pdf_file # for older versions of spree_print_invoice
When the order state changes to complete, spree_print_invoice
creates an database entry for the PDF, but does not render the file right away. If you want to accomplish that, put the following into an order decorator app/models/spree/order_decorator.rb
:
Spree::Order.state_machine.after_transition to: :complete, do: :pdf_file
HTH Martin
Hi Martin,
thank you for your help (that solved it) and thanks to all of you for that gem, saved me a lot of time.
Simon
How can I call the document (invoice) constructor from within the checkout process or how can I call print_invoice without having to access the backend?
I would like to have the invoice created and stored as .pdf automatically as soon as the checkout is completed without having to create the invoice for every order manually.
Thank you!