在特定条件下更改Woocommerce新订单电子邮件文本

时间:2018-02-07 04:48:47

标签: php wordpress email woocommerce hook-woocommerce

在woocommerce中,当用户下订单时,它会向管理员和模板文件发送新订单通知yourtheme/woocommerce/emails/admin-new-order.php并且它具有以下代码块

 /**
  * @hooked WC_Emails::email_header() Output the email header
  */
 do_action( 'woocommerce_email_header', $email_heading, $email ); ?>

 <p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>

 <?php
 /**
  * @hooked WC_Emails::customer_details() Shows customer details
  * @hooked WC_Emails::email_address() Shows email address
  */
 do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );

我想改变文字

<p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>

在某些条件下。我可以触发以下条件,

add_action( 'woocommerce_new_order', 'my_own_function',  1, 1  );
function my_own_function( $order_id )
{
    if( certain_condition )
    {
         // change the text <p><?php printf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->get_formatted_billing_full_name() ); ?></p>
     }
}

有没有办法改变文字。

0 个答案:

没有答案