Sunday, December 18, 2022
HomeWordPress DevelopmentHow can I utterly change the woocommerce "order accomplished" e-mail template in...

How can I utterly change the woocommerce “order accomplished” e-mail template in my plugin?


In a plugin I am engaged on, we wish to change the customer_completed_order template.

I have been experimenting with the wc_get_template filter with no luck. Can somebody inform me the place I am going fallacious please?

I do know my code is fallacious however I am going round in circles attempting to work out how/the place I’ve gone fallacious as a result of the documentation on this filter seems considerably slim (until I’ve not stumbled throughout the precise one)


    public perform __construct() {
        add_filter( 'wc_get_template', array( $this, 'bkf_replace_template' ) );
        outline( 'CUSTOM_WC_EMAIL_PATH', plugin_dir_path( __FILE__ ) );
    }

    public perform bkf_replace_template( $positioned, $template_name, $args, $template_path, $default_path ) {
    if( $template_name == 'emails/customer-completed-order.php'){
        $positioned = trailingslashit( CUSTOM_WC_EMAIL_PATH ) . 'templates/' . $template_name;
    }
    return $positioned;
    }
    
}

Thanks 🙂

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments