之前我曾经问过这个,但不幸的是我意识到答案没有用,所以我再问:
我正在尝试将一些文字添加到$('#certButton').delay(500).animate({ 'opacity': [ 1, "linear" ]}, {
duration:500,
complete: function() {
document.getElementById("certButton").style.pointerEvents = "visible";
}
});
的客户订单处理电子邮件中,并且只应在此特定电子邮件中添加,并且仅在选择的付款方式为WooCommerce
时才会添加。我已经添加了文本,只有当Paypal被选为付款方式时,文本才会显示在每封给客户的电子邮件中,例如也可以在订单完成的电子邮件或客户备注电子邮件中显示。我有以下内容:
Paypal
我尝试过其他条件,比如! add_action('woocommerce_email_before_order_table','add_order_email_instructions', 0, 2);
function add_order_email_instructions( $order, $sent_to_admin ) {
if ( 'paypal' == $order->payment_method && ! $sent_to_admin ) {
echo 'my text:';
}
}
,但没有任何效果。有什么帮助吗?
答案 0 :(得分:2)
我只想在状态为“暂停”并发送给管理员(而不是客户)的电子邮件中添加注释。这对我很有用:
/* Add manual processing note to new orders to admin */
add_action( 'woocommerce_email_order_details','add_order_email_instructions', 10, 4 );
function add_order_email_instructions( $order, $sent_to_admin, $plain_text, $email ) {
if ( $order->status == 'on-hold' && $sent_to_admin ) {
echo '<p><strong>Note: Manual processing for this order is required.</strong></p>';
}
}
答案 1 :(得分:1)
行动......我不知道为什么我认为你的电子邮件根本没有解雇。
顺便说一下,如果您只想将该文本添加到特定的电子邮件模板,有两种方法:
1)更难的一个:禁用客户订单处理&#39;并创建自己的电子邮件模板。您可以从本教程开始:https://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/
2)更容易和推荐:覆盖&#39; customer-order-processing.php&#39;并在该模板中添加一些代码。
这是步骤:
open&#39; customer-processing-order.php&#39;并在您喜欢的地方添加所需的代码:
if(&#39; paypal&#39; == $ order-&gt; payment_method){ 回声我的文字:&#39 ;; }
代码未经过测试但应该有效!
祝你好运;)答案 2 :(得分:1)
我相信我的补丁应该可以通过 WooCommerce 2.5 获得。如果是,则$email
对象将在woocommerce_email_before_order_table
挂钩(以及电子邮件中的其他挂钩)上可用,您将能够针对特定电子邮件测试$email->id
。您functions.php
(或最好是插件)中的以下内容应该是这样的:
add_action( 'woocommerce_email_before_order_table','add_order_email_instructions', 10, 4 );
function add_order_email_instructions( $order, $sent_to_admin, $plain_text, $email ) {
if ( 'customer_processing_order' == $this->id && 'paypal' == $order->payment_method && ! $sent_to_admin ) {
echo 'my text:';
}
}