我尝试删除已完成订单和客户发票电子邮件中的订单信息部分。
无法在以下内容中找到删除方法:
wp-content/plugins/woocommerce/templates/emails/customer-completed-order.php
<?php
/**
* Subscription information template
*
* @author Brent Shepherd / Chuck Mac
* @package WooCommerce_Subscriptions/Templates/Emails
* @version 1.5
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
?>
<?php if ( ! empty( $subscriptions ) ) : ?>
<h2><?php esc_html_e( 'Order Information:', 'woocommerce-subscriptions' ) ?></h2>
<table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee">
<thead>
<tr>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'Order', 'woocommerce-subscriptions' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'Start Date', 'woocommerce-subscriptions' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'End Date', 'woocommerce-subscriptions' ); ?></th>
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php esc_html_e( 'Price', 'woocommerce-subscriptions' ); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ( $subscriptions as $subscription ) : ?>
<tr>
<td scope="row" style="text-align:left; border: 1px solid #eee;"><a href="<?php echo esc_url( ( $is_admin_email ) ? wcs_get_edit_post_link( $subscription->id ) : $subscription->get_view_order_url() ); ?>"><?php echo esc_html( $subscription->get_order_number() ); ?></a></td>
<td scope="row" style="text-align:left; border: 1px solid #eee;"><?php echo esc_html( date_i18n( wc_date_format(), $subscription->get_time( 'start', 'site' ) ) ); ?></td>
<td scope="row" style="text-align:left; border: 1px solid #eee;"><?php echo esc_html( ( 0 < $subscription->get_time( 'end' ) ) ? date_i18n( wc_date_format(), $subscription->get_time( 'end', 'site' ) ) : __( 'When Cancelled', 'woocommerce-subscriptions' ) ); ?></td>
<td scope="row" style="text-align:left; border: 1px solid #eee;"><?php echo wp_kses_post( $subscription->get_formatted_order_total() ); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
请告知。
答案 0 :(得分:1)
您不想删除整个操作挂钩。这可能会影响依赖它的其他插件的存在。 (更不用说订单详细信息在woocommerce_email_order_details
详细信息挂钩上,而不是woocommerce_email_order_meta
挂钩。
从所有电子邮件中删除订单详细信息的正确方法是删除WC_Emails::order_details()
的回调函数,该函数已添加到woocommerce_email_order_details
hook here
您无法直接呼叫remove_action()
,因此必须在add_action()
回调中将其添加到其中之后,但必须先将其添加到其中,但在运行之前。在这种情况下,我们只是潜入同一个钩子,但具有较早的优先级。另请注意,remove_action()
必须与您尝试删除的add_action()
具有相同的优先级。
function so_39251827_remove_order_details( $order, $sent_to_admin, $plain_text, $email ){
$mailer = WC()->mailer(); // get the instance of the WC_Emails class
remove_action( 'woocommerce_email_order_details', array( $mailer, 'order_details' ), 10, 4 );
}
add_action( 'woocommerce_email_order_details', 'so_39251827_remove_order_details', 5, 4 );
编辑:使用说明
emails/customer-completed-order.php
模板并将其从主题中删除。您无需直接编辑即可解决此问题。 functions.php
或最好是自定义代码段插件,例如this one。 编辑#2:仅删除订阅信息
用以下内容替换上述代码:
function so_39251827_remove_subscription_details( $order, $sent_to_admin, $plain_text, $email ){
remove_action( 'woocommerce_email_after_order_table', array( 'WC_Subscriptions_Order', 'add_sub_info_email' ), 15, 3 );
}
add_action( 'woocommerce_email_after_order_table', 'so_39251827_remove_subscription_details', 5, 4 );
答案 1 :(得分:-1)
删除此部件应修复作业
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
答案 2 :(得分:-1)
do_action('woocommerce_email_order_meta',$ order,$ sent_to_admin,$ plain_text);
尝试删除此挂钩。