php - 使用 php 更改使用的 woocommerce 电子邮件模板(不自定义模板)
问题描述
电子邮件营销提供商 SendInBlue 向我提出了一个问题。
长话短说,SendInBlue 只允许您将默认的 woocommerce 电子邮件映射到他们的软件中创建的模板。
我遇到的问题是我们使用了三个无法映射的自定义模板。
我认为可能可行的一种解决方案是创建一个更改我的自定义电子邮件的函数,使用 woocommerce 新订单模板,然后将其映射到 SendInBlue 新订单模板。
这是可能的吗?如果有人能够对此问题提供任何意见,将不胜感激。
谢谢
.
额外的
我正在使用 SendinBlue Woocommerce 插件 - https://wordpress.org/plugins/woocommerce-sendinblue-newsletter-subscription/
这是您将 Woocommerce 电子邮件映射到 SendinBlue 模板的管理页面的屏幕截图https://ps.w.org/woocommerce-sendinblue-newsletter-subscription/trunk/screenshot-3.png?rev=1745315
解决方案
WooCommerce 使用wc_locate_template
过滤器来加载他们的模板。
您可以使用此过滤器有条件地加载特定模板或返回默认值。这不会具体回答您的问题,但会为您提供如何解决此问题的大致方向。
我在使用 WooCommerce 时尝试在我的 WP 主题中使用刀片模板时遇到了类似的问题。
/**
* 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');
推荐阅读
- amazon-web-services - 如何访问在亚马逊 lex 的机器人内部创建的所有意图?
- imagemagick - 如何在不改变速度的情况下改变 gif 的延迟
- scala - 编组 akka-http
- symfony - 使用 symfony 3 的学说进行 mysql 查询时出现内部服务器错误 500
- amazon-web-services - amazon Rekognition 如何处理数据隐私?
- python - tf.dataset does not append batches
- svn - 仅显示已修改的颠覆修订的命令是什么
- android - 可扩展的 ListView,其中包含自定义网格布局
- django - 操作默认的 django 标准输出日志
- excel - 在 Microsoft Excel 中处理 VBA 弹出消息框