Fixed: WooCommerce 3.2.x Customer Details and Cancelled Email Not Working
Advertisement
This is just another snippet, this time for WordPress WooCommerce plugin having a not so good incremental update as it hides Customer Details in an Email and stops working Cancelled Email functionality.
Let’s go
Customer Details
Snippet below added Customer Details manually to each email by adding hook to woocommerce_email_customer_details
.
add_action( 'woocommerce_email_customer_details', 'woocommerce_email_customer_details_func', 20, 3 );
function woocommerce_email_customer_details_func( $order, $sent_to_admin, $plain_text ) {
$phone = $order->get_billing_phone();
$email = $order->get_billing_email();
?>
<h3><?php _e( 'Customer details', 'woocommerce' ); ?></h3>
<table style="margin-bottom:30px;width:100%;vertical-align:top">
<tr>
<td style="padding:0">
<strong><?php echo __('Email Address'); ?>:</strong> <?php echo $phone; ?>
</td>
</tr>
<tr>
<td style="padding:0">
<strong><?php echo __('Phone'); ?>:</strong> <?php echo $email; ?>
</td>
</tr>
</table>
<?php
}
Cancelled Email
Snippet below send Cancelled email by manually hoking to woocommerce_order_status_pending_to_cancelled
add_action('woocommerce_order_status_pending_to_cancelled', 'rstheme_cancelled_send_an_email_notification', 10, 2 );
/**
* Send Cancelled Email
*/
function rstheme_cancelled_send_an_email_notification( $order_id, $order ){
$email_notifications = WC()->mailer()->get_emails();
$email_notifications['WC_Email_Cancelled_Order']->trigger( $order_id );
}
That’s it, happy fixing.
Advertisement