Hello @petrus006
Yes, you need to define the directory for your custom template and update the template name custom_template
:
add_filter( 'wpo_wcpdf_template_paths', 'wpo_wcpdf_template_paths_custom', 10, 1 );
function wpo_wcpdf_template_paths_custom( $template_paths ) {
// $template_paths is an array of BASE paths where the plugin will look for subfolders containing the templates
// $template_paths['default'] // replace the default
// $template_paths['child-theme'] // replace the child-theme
// $template_paths['theme'] // replace the theme
$template_paths['custom_template'] = plugin_dir_path( __FILE__ );
return $template_paths;
}
If you never worked with actions/filters please read this documentation page: How to use filters
-
This reply was modified 3 years, 8 months ago by alexmigf.
Thread Starter
Petrus
(@petrus006)
Hello Alex,
Thanks for your quick reply. I’ll work this out.
Regards,
Petrus
Hello @petrus006
I have updated my answer, i believe you just need one filter to define the custom template path.
Let me know.
Thread Starter
Petrus
(@petrus006)
As you will notice, I’m not very known with functions.
I guess I have to uncomment these lines and place a path in it?
——
// $template_paths[‘default’] // replace the default
// $template_paths[‘child-theme’] // replace the child-theme
// $template_paths[‘theme’] // replace the theme
——
Leaving it like this, the code looks in the folder php of the code snippets plugin.
I’m a bit stuck in this.
Regards,
Petrus
Hi @petrus006
Try this instead:
add_filter( 'wpo_wcpdf_template_paths', 'wpo_wcpdf_template_paths_custom', 10, 1 );
function wpo_wcpdf_template_paths_custom( $template_paths ) {
$template_paths['my-custom-template'] = get_template_directory().'/woocommerce/pdf/my-custom-template/';
return $template_paths;
}
Don’t forget to replace the my-custom-template
on the snippet.
You can find more about custom templates here: Creating a custom PDF template
-
This reply was modified 3 years, 8 months ago by alexmigf.
Hi @petrus006
My previous code snippet it’s not correct and will not work because Oxygen doesn’t allow theme templates.
Please use this small extension i created https://github.com/wpovernight/custom-pdf-template-extension/releases/tag/v1.0.0 and follow the instructions here.
Let me know.
Thread Starter
Petrus
(@petrus006)
Hello alexmigf,
Works perfectly. Thanks a lot.
I think more Oxygen users will face the same problem. I would like to post your solution on the Oxygen users Facebook group. If you’re OK with that, which credentials shall I use?
Regards,
Petrus
Hi @petrus006
Glad it’s working!
I believe you don’t need any credentials, the extension is public 🙂
-
This reply was modified 3 years, 8 months ago by alexmigf.