我在之前的线程中发现了这个代码(它确实有效),它可以为选择本地取货作为送货方式的客户发送电子邮件的自定义消息。
add_action( 'woocommerce_email_order_details',
'my_completed_order_email_instructions', 10, 4 );
function my_completed_order_email_instructions( $order,
$sent_to_admin, $plain_text, $email ) {
// Only for processing and completed email notifications to customer
if( ! ( 'customer_processing_order' == $email->id ||
'customer_completed_order' == $email->id ) ) return;
foreach( $order->get_items('shipping') as $shipping_item ){
$shipping_rate_id = $shipping_item->get_method_id();
$method_array = explode(':', $shipping_rate_id );
$shipping_method_id = reset($method_array);
// Display a custom text for local pickup shipping method only
if( 'local_pickup' == $shipping_method_id ){
echo '<p><strong>Ritiro in sede</strong></p>';
break;
}
}
现在我的问题是:如何调整代码以删除处理订单电子邮件,使其仅涵盖已完成的订单电子邮件?