Как сделать отправку письма клиенту при отмене заказа в WooCommerce

В стандартных настройках Email уведомлений WooCommerce при изменении статуса заказа на «отменен», письмо отправляется только администратору сайта. При необходимости отправки письма клиенту об отмене заказа, необходимо в файл темы function.php добавить следующий код:

				
					add_action('woocommerce_order_status_changed', 'send_custom_email_notifications', 10, 4 
); function send_custom_email_notifications( $order_id, $old_status, $new_status, $order 
){ if ( $new_status == 'cancelled' || $new_status == 'failed' ){ $wc_emails = WC
()->mailer()->get_emails(); // Get all WC_emails objects instances $customer_email = 
$order->get_billing_email(); // The customer email } if ( $new_status == 'cancelled' ) { 
// change the recipient of this instance $wc_emails['WC_Email_Cancelled_Order']
->recipient = $customer_email; // Sending the email from this instance 
$wc_emails['WC_Email_Cancelled_Order']->trigger( $order_id ); } elseif ( $new_status == 
'failed' ) { // change the recipient of this instance 
$wc_emails['WC_Email_Failed_Order']->recipient = $customer_email; // Sending the email 
from this instance $wc_emails['WC_Email_Failed_Order']->trigger( $order_id ); } }
				
			

2 способ:

Плагин для получения писем об отмене заказа — https://shopmagic.app/blog/woocommerce-cancel-order-email/

Поделись с друзьями или сохрани себе:

VK
Facebook
Telegram
WhatsApp

Комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Привет! Я - Андрей. Занимаюсь обучением и разработкой сайтов на CMS WordPress и Elementor.

Мой ТОП хостингов в РФ

Мой ТОП хостингов в РБ

Хостинг за крипту в Европе