Я хочу остановить уведомление по электронной почте woocommerce, если стоимость заказа $0.00
Я использовал этот код:
function restrict_admin_new_order_mail( $recipient, $order ) {
if( $order->get_total() === '0.00' ) {
return;
} else {
return $recipient;
}
}
add_filter('woocommerce_email_recipient_new_order', 'restrict_admin_new_order_mail', 1, 2);
Код работает, но я получил эту фатальную ошибку, все параметры электронной почты исчезли в настройках Woocommerce (см. Прикрепленный снимок экрана).
Error Details
=============
[13-Jan-2021 17:34:15 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_total() on null in C:\Users\joe\Local Sites\staging\app\public\wp-content\themes\flatsome-child\functions.php:8
Stack trace:
#0 C:\Users\joe\Local Sites\staging\app\public\wp-includes\class-wp-hook.php(289): restrict_admin_new_order_mail('email@gmail....', NULL)
#1 C:\Users\joe\Local Sites\staging\app\public\wp-includes\plugin.php(206): WP_Hook->apply_filters('email@gmail....', Array)
#2 C:\Users\joe\Local Sites\staging\app\public\wp-content\plugins\woocommerce\includes\emails\class-wc-email.php(399): apply_filters('woocommerce_ema...', 'email@gmail....', NULL, Object(WC_Email_New_Order))
#3 C:\Users\joe\Local Sites\staging\app\public\wp-content\plugins\woocommerce\includes\admin\settings\class-wc-settings-emails.php(294): WC_Email->get_recipient()
#4 C:\Users\joe\Local Sites\staging\app\public\wp-includes\class-wp-hook.php(287): WC_Settings_Emails->email_notification_setting(Array)
#5 C:\Users\joe\Local Sites\staging\app\public\wp-includes\ in C:\Users\joe\Local Sites\staging\app\public\wp-content\themes\flatsome-child\functions.php on line 8
Любая помощь, пожалуйста? Спасибо