我试图删除订单信息部分,在一个完整的订单和客户发票电子邮件。

中无法找到如何删除此内容:
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; ?>请给我建议。
发布于 2016-08-31 15:10:41
你不想移除整个动作钩子。这可能会影响到其他依靠它的存在的插件。(更不用说订单细节是在woocommerce_email_order_details详细信息钩子上,而不是woocommerce_email_order_meta钩子上)。
从所有电子邮件中删除订单详细信息的正确方法是删除它们的回调函数,即WC_Emails::order_details(),它被添加到钩在这里中
您不能直接调用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中,或者最好是一个自定义代码段插件,比如这一个。编辑#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 );发布于 2016-08-31 14:26:11
移除此部分应修复作业。
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
发布于 2016-08-31 14:33:57
do_action( 'woocommerce_email_order_meta',$order,$sent_to_admin,$plain_text );
试着移除这个钩子。
https://stackoverflow.com/questions/39251827
复制相似问题