• Resolved Petrus

    (@petrus006)


    Hello

    I am using PDF Invoices & Packing Slips with Oxygen Builder. For the Invoices I would like to make my own template. Normally this is placed in a child theme folder called fake/woocommerce/pdf/yourtemplate.
    Because Oxygen disables the WordPress theme system, I can’t use a child theme.
    Is there a way, using Code Snippets plugin, to solve this problem?

    Regards,
    Petran

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    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

    Plugin Contributor alexmigf

    (@alexmigf)

    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

    Plugin Contributor alexmigf

    (@alexmigf)

    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.
    Plugin Contributor alexmigf

    (@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

    Plugin Contributor alexmigf

    (@alexmigf)

    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.
    Thread Starter Petrus

    (@petrus006)

    Done.
    Thanks again.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Use PDF Invoices & Packing Slips with Oxygen Builder’ is closed to new replies.