WooCommerce - 从woocommerce_email_order_details中删除特定元素

时间:2017-05-01 10:26:30

标签: wordpress woocommerce hook-woocommerce

如何从 woocommerce_email_order_details 中删除仅第一行(产品名称,数量和价格)?

This is how email looks right now

目前admin_new_order.php包含以下代码

<?php    

 if ( ! defined( 'ABSPATH' ) ) {
    exit;
 }


 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


 do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );


 do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );


 do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );


 do_action( 'woocommerce_email_footer', $email );

woocommerce_email_order_details 是创建您在图片中看到的所有元素的函数。我知道我不应该删除整个函数,因为其他函数可能正在使用此函数。那么我如何只访问第一行以便我可以将其删除?

1 个答案:

答案 0 :(得分:1)

试试这个

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 );