- Issue created by @henkpotman
- πΊπΈUnited States lisastreeter
Hi! I'm not sure why you're having trouble--it sounds like you want to do precisely what this module is designed to do.
If you select "Default" as the plugin, set the machine name for your document type to "factura", and create template 'commerce-order-document--factura.html.twig' in your custom theme, that theme should be used for your "Factura" documents. You don't need to "select" anything in the configuration. The code is written in a way that first Drupal will attempt to find a template named 'commerce-order-document--factura.html.twig' and then only use the standard 'commerce-order-document.html.twig' template if the document-type-specific template can't be found. Maybe try rebuilding caches?
I'm doing it right now for a order document type named "proforma." Here are screenshots:
- πΊπΈUnited States lisastreeter
One more comment, regarding your solution in the "Proposed Resolution." It is possible to provide more options than just Default and Receipt. However, to do so you need to write custom code to implement a new Order Document plugin. In one of my screenshots above, there's an "Invoice" option. That appears because I have custom plugin code that starts like this:
<?php namespace Drupal\my_module\Plugin\Commerce\OrderDocument; use Drupal\commerce_order\Entity\OrderInterface; use Drupal\commerce_order_document\Plugin\Commerce\OrderDocument\OrderDocumentBase; use Drupal\commerce_order_document\Plugin\Commerce\OrderDocument\OrderDocumentInterface; /** * Provides the Invoice order document. * * @CommerceOrderDocument( * id = "my_invoice", * label = "Invoice", * display_label = "Invoice", * ) */ class MyInvoice extends OrderDocumentBase implements OrderDocumentInterface {
And then in my
buildOrderDocument
I explicitly set the theme (template) that should be used to generate documents. That template file can have any name I want. It's not limited to thecommerce-order-document--DOCUMENT-ID.html.twig
format. For example, the template for this plugin could be namedmy-order-invoice.html.twig
or anything else I want. - πͺπΈSpain henkpotman
Thanks very much for your extensive comments and information!
I found my mistake. I placed the custom templates in the commerce_order_document/templates folder. According to your indications it should be places in the theme templates folder. I did and now it's working fine!
I think your module is great, just what many people will need to make any type of document (packing slips, proforma invoice, invoice..).
You made my day! Again, thanks a lot for your time and help!
- Status changed to Closed: works as designed
about 1 year ago 5:06pm 23 September 2023