Plugin Contributor
Ewout
(@pomegranate)
yes, anything that should be update proof and is not actually part of the invoice layout should go into functions.php of your child theme, or template-functions.php in the template folder if you prefer that to keep things orderly.
Especially if these are actions/filters. You could also use the Code Snippets plugin. More information: How to use filters
You can’t have just one file of the template, you will need all the files. If you just copy style.css it may not pick it up (not 100% sure). Even for styles you can use an action hook so that you never need to touch the template files and you’re always up to date: Using custom styles.
When you say ‘Sometimes this doesnβt seem to work’. Does that mean it doesn’t turn up in the Template selection in the General PDF invoice settings? Is this with a full copy with all the template files?
Editing files in the plugin folder is possible, but this will be overwritten by every plugin update, so not a very sustainable solution π
For a detailed explanation of the procedure: Creating a custom PDF template
Ewout
Thread Starter
Rixter
(@myrax)
Hi Ewout, thanks for your quick reply (at this hour π ).
Don’t want to use the plugin; I try to avoid adding too much plugins.
Hence: child theme / php.
Actually: using only style.css worked fine… I put it in the folder woocommerce/pdf/[name template] of my child theme. Somehow it derives the other php.files from of the simple-folder elsewhere when a generate an invoice But I do get why it might not. Not sure how or when these php-files are kicking in.
The thing is: the invoice.php changed some time ago. Because I copied all the template files to my child theme, this php-file didn’t work anymore. So if I don’t have to copy them at all it would be better and safer with updates (or so I thought).
Yes, it sometimes ‘doesnt’ work’ because I can not select the template in the general settings. But this is with using ALL files in the template. Lately it works fine though, I was just wondering.
I thought the files would not be overwritten because they would be in their own folder [name template]. I guess when the folder structure changes as well, all is lost indeed. I stick with folder in child theme. π
Thread Starter
Rixter
(@myrax)
Hi Ewout,
Can you please get back to me on the one thing I mentioned?
“The thing is: the invoice.php changed some time ago. Because I copied all the template files to my child theme, this php-file didnβt work anymore. So if I donβt have to copy them at all it would be better and safer with updates (or so I thought).”
How can I make sure I don’t run into problems in the futere?
When you do an update of the plugin and the invoice.php in the Simple folder gets altered, my invoice.php in my child theme doesn’t get altered the same way. Recently my custom template broke because of this after an update.
I have several clients using your plugin π and can’t afford broken templates actually…
Plugin Contributor
Ewout
(@pomegranate)
Yes, if you create a custom template, you’ll have to maintain it. If you don’t want that, you’ll have to use the bundled template – simple as that.
The 2.0 update as big in terms of changes to the template, but big updates like that don’t happen very often (only every 2-3 years). As a general rule, don’t roll out plugin updates before testing (this holds for any WP plugin!), especially big updates.
The 2.0 update was even largely backwards compatible, so if your template broke it probably meant that you were using exotic functions.
Some things that help preventing this in the future:
- Keep customizations to an absolute minimum, and avoid using functions that are not used in the default template
- Always use action hooks where you can, if you can do your customizations with only action hooks this means you can keep using the bundled template and only need to update the action hooks when something breaks (which is then also much less likely)
Finally, if something breaks because of an update and you post it here I may still be able to fix this so that it remains backwards compatible.
Hope that helps!
Ewout