php – 从woocommerce的电子邮件模板中删除订单信息部分
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 从woocommerce的电子邮件模板中删除订单信息部分,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3623字,纯文字阅读大概需要6分钟。
内容图文
我正在尝试删除已完成订单和客户发票电子邮件中的订单信息部分.
在以下位置找不到如何删除这个:
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; ?>
请指教.
解决方法:
您不想删除整个操作挂钩.这可能会影响依赖它的其他插件. (更不用说订单详细信息在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 );
编辑:使用说明
>停止覆盖电子邮件/ 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 );
内容总结
以上是互联网集市为您收集整理的php – 从woocommerce的电子邮件模板中删除订单信息部分全部内容,希望文章能够帮你解决php – 从woocommerce的电子邮件模板中删除订单信息部分所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。