2

I've been presented with a problem from SendInBlue, the email marketing provider.

To cut a long story short, SendInBlue only allows you to map the default woocommerce emails to the templates created in their software.

The problem I have is we use three custom templates which I cannot map.

One solution I thought maybe viable would be to create a function that changes my custom email use the woocommerce new order template which would in turn then be mapped to the SendInBlue new order template.

Is this something that's possible? if anyone is able to offer any input to this problem it would be greatly appreciated.

Thanks

.

ADDITIONAL

Im using the SendinBlue Woocommerce plugin - https://wordpress.org/plugins/woocommerce-sendinblue-newsletter-subscription/

This is a screenshot of the admin page where you map your Woocommerce email to the SendinBlue template https://ps.w.org/woocommerce-sendinblue-newsletter-subscription/trunk/screenshot-3.png?rev=1745315

blackhill24
  • 422
  • 14
  • 30
  • 1
    Can you be more specific? Don't really understand what you mean here. If you map the templates to theirs, doesn't their tpl just override the behavior? – TurtleTread Jul 10 '18 at 18:41
  • No, the problem is SendinBlue only let you choose their templates for new / cancelled and failed orders. My custom emails still use the default woocommerce templates. It's these emails I want changed to use the SendinBlue New Order template – blackhill24 Jul 11 '18 at 13:54
  • I assume you are using the plugin SendinBlue Add-on to select templates? What are the custom templates? Are they actually page templates directly under theme dir or just also wc templates overrides in your theme's woocommerce folder? but I think your suggested answer of fetching the wc templates is the simplest method, otherwise you have to find hooks to try to extend the system. – TurtleTread Jul 11 '18 at 14:55
  • Is SendInBlue site built in wordpress? – Sudharshan Nair Jul 12 '18 at 11:43
  • thanks for getting back to me @TurtleTread... The SendinBlue Plugin gives you the option to map each woocommerce email to a template create on the SendinBlue website. I have not edited our store theme / plugin in anyway. – blackhill24 Jul 12 '18 at 18:22
  • @Sudharshan Nair - ive updated the question with the plugin im using – blackhill24 Jul 12 '18 at 18:26
  • You haven't explained what your custom templates are? – TurtleTread Jul 12 '18 at 18:51
  • You mean you are going to create new templates, and you need options to map it to SendInBlue ? – Sudharshan Nair Jul 13 '18 at 05:19
  • @Sudharshan Nair that is correct – blackhill24 Jul 13 '18 at 12:55
  • @blackhill24. You have to customize in that plugin or use hooks if that plugin provides. – Sudharshan Nair Jul 13 '18 at 12:56

1 Answers1

2

WooCommerce uses the wc_locate_template filter to load their templates.

You can use this filter to conditionally load specific templates or return the default. This will not answer your question specifically, but will give you a general direction of how to solve this problem.

I ran into a similar problem trying to use blade templates in my WP theme when using WooCommerce.

/**
 * Conditionally filter the email template WooCommerce chooses.
 *
 * @filter wc_locate_template
 * @param  {string}  $template   Full file path to original woo template
 * @return {string}              Full path to desired template to render
 */
function filter_wc_email_templates($template) {
    // Psuedo code
    $target = 'order-confirmation.php';
    $replacement = 'shipping-confirmation.php';
    $isTargetFile = strstr($template, $target) !== false;

    if (! $isTargetFile) {
        // if this is not the file we want to modify functionality for
        // just retrun the default one
        return $template;
    } else {
        // if this is the target file we want to replace
        // return the full path to the file of the template we want to use
        return getThemeTemplatePath() . '/<path to WooCommerce in your theme>/' . $replacement;
    }
});

add_filter('wc_locate_template', 'filter_wc_email_templates');
domdambrogia
  • 2,054
  • 24
  • 31