В настоящее время я столкнулся с проблемой.
Мой пользовательский статус электронной почты раньше работал, но внезапно перестал работать. Я могу установить статус, но он не отправляет электронное письмо. Другой стандартный статус работает без проблем.
Я использовал отладку, чтобы проверить, какие ошибки я могу обнаружить, и вижу, что веб-сайт видит, что он меняет статус, но не запускает отправку электронная почта, я удалил все строки отладки в коде.
Я использую hello elementor в качестве основной темы, а сайт работает на PHP версии 8.3
Вот пара строки отладки
[23 июля 2024 г., 06:54:18 UTC] Статус заказа изменен: идентификатор заказа 6568 с checkout-draft на uwretourontvangen
[23- Июль 2024 г., 06:54:18 UTC] Класс WC_uwretourontvangen_Status_Email создан
[23 июля 2024 г., 06:54:18 UTC] Класс WC_uwretourontvangen_Status_Email зарегистрирован
Я использую версию woocommerce 9.1.2
Это мой код
function register_uwretourontvangen_order_status() {
register_post_status( 'wc-uwretourontvangen', array(
'label' => 'Uw retour ontvangen',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Uw retour ontvangen (%s)', 'Uw retour ontvangen (%s)' )
) );
}
add_action( 'init', 'register_uwretourontvangen_order_status' );
add_filter( 'wc_order_statuses', function( $order_statuses ) {
$order_statuses['wc-uwretourontvangen'] = _x( 'Uw retour ontvangen', 'Order status', 'woocommerce' );
return $order_statuses;
});
add_action( 'woocommerce_email_classes', function ( $email_classes ) {
class WC_uwretourontvangen_Status_Email extends WC_Email {
public function __construct() {
$this->id = 'wc-uwretourontvangen';
$this->title = 'Uw Retour ontvangen';
$this->description = 'An email sent when order status changes to retour.';
$this->heading = 'Wij hebben uw retour ontvangen';
$this->subject = 'Uw retour ontvangen';
$this->template_html = 'emails/admin-retourontvangen-status.php';
$this->template_plain = 'emails/plain/admin-retourontvangen-statusplain.php';
parent::__construct();
add_action( 'woocommerce_order_status_uwretourontvangen', array( $this, 'trigger' ), 10, 2 );
}
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->recipient = $this->object->get_billing_email();
if ( $this->is_enabled() && $this->get_recipient() ) {
$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
}
}
}
public function get_content_html() {
ob_start();
wc_get_template( $this->template_html, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => false,
'email' => $this
) );
return ob_get_clean();
}
public function get_content_plain() {
ob_start();
wc_get_template( $this->template_plain, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => true,
'email' => $this
) );
return ob_get_clean();
}
}
$email_classes['WC_uwretourontvangen_Status_Email'] = new WC_uwretourontvangen_Status_Email();
return $email_classes;
});
Я видел в stackoverflow использование другого типа кода
поэтому я попытался создать такой код, но безуспешно, но все равно то же самое, я могу поставить статус "uw retour ontvangen", но он не отправляет электронное письмо
add_action( 'init', 'register_uwretourontvangen_order_status', 20 );
function register_uwretourontvangen_order_status() {
register_post_status( 'wc-uwretourontvangen', array(
'label' => _x( 'Uw retour ontvangen', 'Order status', 'woocommerce' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Uw retour ontvangen (%s)', 'Uw retour ontvangen (%s)', 'woocommerce' )
) );
}
add_filter( 'wc_order_statuses', 'custom_wc_order_statuses' );
function custom_wc_order_statuses( $order_statuses ) {
$order_statuses['wc-uwretourontvangen'] = _x( 'Uw retour ontvangen', 'Order status', 'woocommerce' );
return $order_statuses;
}
add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 20, 1 );
function custom_dropdown_bulk_actions_shop_order( $actions ) {
$actions['mark_uwretourontvangen'] = __( 'Uw retour ontvangen', 'woocommerce' );
return $actions;
}
add_filter( 'woocommerce_email_actions', 'custom_email_actions', 20, 1 );
function custom_email_actions( $actions ) {
$actions[] = 'woocommerce_order_status_uwretourontvangen';
return $actions;
}
add_action( 'plugins_loaded', 'initialize_custom_email_class' );
function initialize_custom_email_class() {
if ( ! class_exists( 'WC_Email_Uwretourontvangen' ) ) {
class WC_Email_Uwretourontvangen extends WC_Email {
public function __construct() {
$this->id = 'uwretourontvangen';
$this->title = 'Uw Retour ontvangen';
$this->description = 'This is an order notification sent to the customer when their order is marked as Uw Retour ontvangen.';
$this->heading = 'Wij hebben uw retour ontvangen';
$this->subject = 'Uw retour ontvangen';
$this->template_html = 'emails/admin-retourontvangen-status.php';
$this->template_plain = 'emails/plain/admin-retourontvangen-statusplain.php';
$this->customer_email = true;
add_action( 'woocommerce_order_status_uwretourontvangen_notification', array( $this, 'trigger' ), 10, 2 );
parent::__construct();
$this->template_base = plugin_dir_path( __FILE__ ) . 'templates/';
}
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->recipient = $this->object->get_billing_email();
if ( $this->is_enabled() && $this->get_recipient() ) {
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
}
}
public function get_content_html() {
ob_start();
wc_get_template( $this->template_html, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => false,
'email' => $this
), '', $this->template_base );
return ob_get_clean();
}
public function get_content_plain() {
ob_start();
wc_get_template( $this->template_plain, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => true,
'email' => $this
), '', $this->template_base );
return ob_get_clean();
}
public function get_default_subject() {
return __( 'Uw retour ontvangen', 'woocommerce' );
}
public function get_default_heading() {
return __( 'Wij hebben uw retour ontvangen', 'woocommerce' );
}
}
}
add_filter( 'woocommerce_email_classes', 'add_custom_email_class' );
function add_custom_email_class( $email_classes ) {
$email_classes['WC_Email_Uwretourontvangen'] = new WC_Email_Uwretourontvangen();
return $email_classes;
}
add_action( 'woocommerce_order_status_uwretourontvangen', 'trigger_custom_email_notification', 20, 2 );
function trigger_custom_email_notification( $order_id, $order ) {
$mailer = WC()->mailer();
$mails = $mailer->get_emails();
if ( ! empty( $mails ) && isset( $mails['WC_Email_Uwretourontvangen'] ) ) {
$mails['WC_Email_Uwretourontvangen']->trigger( $order_id );
}
}
}
add_filter( 'woocommerce_email_settings', 'add_custom_email_setting' );
function add_custom_email_setting( $settings ) {
$settings[] = array(
'title' => __( 'Uw Retour ontvangen', 'woocommerce' ),
'id' => 'uwretourontvangen',
'type' => 'checkbox',
'description' => __( 'Enable this email notification for Uw Retour ontvangen status.', 'woocommerce' ),
'default' => 'yes',
);
return $settings;
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... sion-9-1-2
Пользовательский статус электронной почты Woocommerce не работает, версия 9.1.2 ⇐ Php
Кемеровские программисты php общаются здесь
1721905424
Anonymous
В настоящее время я столкнулся с проблемой.
Мой пользовательский статус электронной почты раньше работал, но внезапно перестал работать. Я могу установить статус, но он не отправляет электронное письмо. Другой стандартный статус работает без проблем.
Я использовал отладку, чтобы проверить, какие ошибки я могу обнаружить, и вижу, что веб-сайт видит, что он меняет статус, но не запускает отправку электронная почта, я удалил все строки отладки в коде.
Я использую hello elementor в качестве основной темы, а сайт работает на PHP версии 8.3
Вот пара строки отладки
[23 июля 2024 г., 06:54:18 UTC] Статус заказа изменен: идентификатор заказа 6568 с checkout-draft на uwretourontvangen
[23- Июль 2024 г., 06:54:18 UTC] Класс WC_uwretourontvangen_Status_Email создан
[23 июля 2024 г., 06:54:18 UTC] Класс WC_uwretourontvangen_Status_Email зарегистрирован
Я использую версию woocommerce 9.1.2
Это мой код
function register_uwretourontvangen_order_status() {
register_post_status( 'wc-uwretourontvangen', array(
'label' => 'Uw retour ontvangen',
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Uw retour ontvangen (%s)', 'Uw retour ontvangen (%s)' )
) );
}
add_action( 'init', 'register_uwretourontvangen_order_status' );
add_filter( 'wc_order_statuses', function( $order_statuses ) {
$order_statuses['wc-uwretourontvangen'] = _x( 'Uw retour ontvangen', 'Order status', 'woocommerce' );
return $order_statuses;
});
add_action( 'woocommerce_email_classes', function ( $email_classes ) {
class WC_uwretourontvangen_Status_Email extends WC_Email {
public function __construct() {
$this->id = 'wc-uwretourontvangen';
$this->title = 'Uw Retour ontvangen';
$this->description = 'An email sent when order status changes to retour.';
$this->heading = 'Wij hebben uw retour ontvangen';
$this->subject = 'Uw retour ontvangen';
$this->template_html = 'emails/admin-retourontvangen-status.php';
$this->template_plain = 'emails/plain/admin-retourontvangen-statusplain.php';
parent::__construct();
add_action( 'woocommerce_order_status_uwretourontvangen', array( $this, 'trigger' ), 10, 2 );
}
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->recipient = $this->object->get_billing_email();
if ( $this->is_enabled() && $this->get_recipient() ) {
$this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
}
}
}
public function get_content_html() {
ob_start();
wc_get_template( $this->template_html, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => false,
'email' => $this
) );
return ob_get_clean();
}
public function get_content_plain() {
ob_start();
wc_get_template( $this->template_plain, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => true,
'email' => $this
) );
return ob_get_clean();
}
}
$email_classes['WC_uwretourontvangen_Status_Email'] = new WC_uwretourontvangen_Status_Email();
return $email_classes;
});
Я видел в stackoverflow использование другого типа кода
поэтому я попытался создать такой код, но безуспешно, но все равно то же самое, я могу поставить статус "uw retour ontvangen", но он не отправляет электронное письмо
add_action( 'init', 'register_uwretourontvangen_order_status', 20 );
function register_uwretourontvangen_order_status() {
register_post_status( 'wc-uwretourontvangen', array(
'label' => _x( 'Uw retour ontvangen', 'Order status', 'woocommerce' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Uw retour ontvangen (%s)', 'Uw retour ontvangen (%s)', 'woocommerce' )
) );
}
add_filter( 'wc_order_statuses', 'custom_wc_order_statuses' );
function custom_wc_order_statuses( $order_statuses ) {
$order_statuses['wc-uwretourontvangen'] = _x( 'Uw retour ontvangen', 'Order status', 'woocommerce' );
return $order_statuses;
}
add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 20, 1 );
function custom_dropdown_bulk_actions_shop_order( $actions ) {
$actions['mark_uwretourontvangen'] = __( 'Uw retour ontvangen', 'woocommerce' );
return $actions;
}
add_filter( 'woocommerce_email_actions', 'custom_email_actions', 20, 1 );
function custom_email_actions( $actions ) {
$actions[] = 'woocommerce_order_status_uwretourontvangen';
return $actions;
}
add_action( 'plugins_loaded', 'initialize_custom_email_class' );
function initialize_custom_email_class() {
if ( ! class_exists( 'WC_Email_Uwretourontvangen' ) ) {
class WC_Email_Uwretourontvangen extends WC_Email {
public function __construct() {
$this->id = 'uwretourontvangen';
$this->title = 'Uw Retour ontvangen';
$this->description = 'This is an order notification sent to the customer when their order is marked as Uw Retour ontvangen.';
$this->heading = 'Wij hebben uw retour ontvangen';
$this->subject = 'Uw retour ontvangen';
$this->template_html = 'emails/admin-retourontvangen-status.php';
$this->template_plain = 'emails/plain/admin-retourontvangen-statusplain.php';
$this->customer_email = true;
add_action( 'woocommerce_order_status_uwretourontvangen_notification', array( $this, 'trigger' ), 10, 2 );
parent::__construct();
$this->template_base = plugin_dir_path( __FILE__ ) . 'templates/';
}
public function trigger( $order_id, $order = false ) {
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->recipient = $this->object->get_billing_email();
if ( $this->is_enabled() && $this->get_recipient() ) {
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
}
}
public function get_content_html() {
ob_start();
wc_get_template( $this->template_html, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => false,
'email' => $this
), '', $this->template_base );
return ob_get_clean();
}
public function get_content_plain() {
ob_start();
wc_get_template( $this->template_plain, array(
'order' => $this->object,
'email_heading' => $this->get_heading(),
'sent_to_admin' => false,
'plain_text' => true,
'email' => $this
), '', $this->template_base );
return ob_get_clean();
}
public function get_default_subject() {
return __( 'Uw retour ontvangen', 'woocommerce' );
}
public function get_default_heading() {
return __( 'Wij hebben uw retour ontvangen', 'woocommerce' );
}
}
}
add_filter( 'woocommerce_email_classes', 'add_custom_email_class' );
function add_custom_email_class( $email_classes ) {
$email_classes['WC_Email_Uwretourontvangen'] = new WC_Email_Uwretourontvangen();
return $email_classes;
}
add_action( 'woocommerce_order_status_uwretourontvangen', 'trigger_custom_email_notification', 20, 2 );
function trigger_custom_email_notification( $order_id, $order ) {
$mailer = WC()->mailer();
$mails = $mailer->get_emails();
if ( ! empty( $mails ) && isset( $mails['WC_Email_Uwretourontvangen'] ) ) {
$mails['WC_Email_Uwretourontvangen']->trigger( $order_id );
}
}
}
add_filter( 'woocommerce_email_settings', 'add_custom_email_setting' );
function add_custom_email_setting( $settings ) {
$settings[] = array(
'title' => __( 'Uw Retour ontvangen', 'woocommerce' ),
'id' => 'uwretourontvangen',
'type' => 'checkbox',
'description' => __( 'Enable this email notification for Uw Retour ontvangen status.', 'woocommerce' ),
'default' => 'yes',
);
return $settings;
}
Подробнее здесь: [url]https://stackoverflow.com/questions/78787123/woocommerce-custom-e-mail-status-not-working-version-9-1-2[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия