从WooCommerce电子邮件中删除订单日期

时间:2019-06-05 13:38:30

标签: php woocommerce

我正试图从woocommerce电子邮件中删除订购日期,但是由于我对PHP不太自信,所以发现自己有些卡住了。

下面是我找到的类似问题的代码(而不是删除订单号,但保留日期...我想做相反的事情。

<?php
// Targetting specific email notificatoins
$email_ids = array('new_order', 'customer_on_hold_order');

$date = sprintf( '<time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) );

// Displaying order number except for "New Order" and "Customer On Hold Order" notifications
if( ! in_array($email->id, $email_ids) ){
    $order_number = sprintf( __( 'Order #%s', 'woocommerce' ), $order->get_order_number() );
    $date = '('.$date.')';
} else {
    $date = __('Order date:', 'woocommerce') . ' ' . $date;
    $order_number = '';
}

if ( $sent_to_admin ) {
    $before = '<a class="link" href="' . esc_url( 

$order->get_edit_order_url() ) . '">';
        $after  = '</a> ';
    } else {
        $before = '';
        $after  = ' ';
    }
?>

<h2><?php echo $before . $order_number . $after . $date; ?></h2>

1 个答案:

答案 0 :(得分:0)

设法自己弄清楚这一点...(尽管不确定这是一种很好的做法...但是可行!)

只需在your-child-theme / woocommerce / emails / email-order-details.php中的h2标签中添加一个类,如下所示:

<h2 class="fbc-time">
<?php
if ( $sent_to_admin ) {
    $before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
    $after  = '</a>';
} else {
    $before = '';
    $after  = '';
}
/* translators: %s: Order ID. */
echo wp_kses_post( $before . sprintf( __( 'Order #%s', 'woocommerce' ) . $after . ' <time datetime="%s">%s</time>', $order->get_order_number(), $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ) );
?>

然后在email-styles.php中选择该类并使用显示:无