Я использую несколько пользовательских статусов заказов, которые успешно добавил в WooCommerce. Мне удалось настроить электронные письма, которые будут отправляться клиенту при заказе определенных типов продуктов. работает,
Теперь я хочу изменить свой код, чтобы он отправлял только настроенные уведомления по электронной почте, а не почту, обрабатываемую WooCommerce по умолчанию.
Вот рабочий пример моего кода:
// register a custom post status 'awaiting-delivery' for Orders
add_action( 'init', 'register_custom_post_status', 20 );
function register_custom_post_status() {
register_post_status( 'wc-custom', array(
'label' => _x( 'Instagram cursus', '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( 'Instagram cursus (%s)', 'Instagram cursus (%s)', 'woocommerce' )
) );
}
// Adding custom status 'awaiting-delivery' to order edit pages dropdown
add_filter( 'wc_order_statuses', 'custom_wc_order_statuses' );
function custom_wc_order_statuses( $order_statuses ) {
$order_statuses['wc-custom'] = _x( 'Instagram cursus', 'Order status', 'woocommerce' );
return $order_statuses;
}
// Adding custom status 'awaiting-delivery' to admin order list bulk dropdown
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_custom'] = __( 'Instagram cursus', 'woocommerce' );
return $actions;
}
// Adding action for 'awaiting-delivery'
add_filter( 'woocommerce_email_actions', 'custom_email_actions', 20, 1 );
function custom_email_actions( $actions ) {
$actions[] = 'woocommerce_order_status_wc-custom';
return $actions;
}
// Removing default email action for 'processing' status
remove_action( 'woocommerce_order_status_processing', array( WC(), 'send_transactional_email' ), 10, 1 );
// Adding action for 'awaiting-delivery'
add_action( 'woocommerce_order_status_changed', 'custom_email_notification', 10, 4 );
function custom_email_notification( $order_id, $old_status, $new_status, $order ) {
$custom_statuses = array( 'custom', 'custom2', 'custom3' );
if ( in_array( $new_status, $custom_statuses ) ) {
// Your settings here
$email_key = 'WC_Email_Customer_Processing_Order'; // The email notification type
// Get specific WC_emails object
$email_obj = WC()->mailer()->get_emails()[ $email_key ];
// Triggering the customized email
$email_obj->trigger( $order_id );
}
}
// Customize email heading for this custom status email notification
add_filter( 'woocommerce_email_heading_customer_processing_order', 'email_heading_customer_awaiting_delivery_order', 10, 2 );
function email_heading_customer_awaiting_delivery_order( $heading, $order ){
if ($order->has_status('custom')) {
$email_key = 'WC_Email_Customer_Processing_Order'; // The email notification type
$email_obj = WC()->mailer()->get_emails()[$email_key]; // Get specific WC_emails object
$heading_txt = __('Bevestigingsmail:','woocommerce'); // New heading text
return $email_obj->format_string( $heading_txt );
}
return $heading;
}
// Customize email subject for this custom status email notification
add_filter( 'woocommerce_email_subject_customer_processing_order', 'email_subject_customer_awaiting_delivery_order', 10, 2 );
function email_subject_customer_awaiting_delivery_order( $subject, $order ){
if ($order->has_status('custom')) {
$email_key = 'WC_Email_Customer_Processing_Order'; // The email notification type
$email_obj = WC()->mailer()->get_emails()[$email_key]; // Get specific WC_emails object
$subject_txt = sprintf( __('[%s] Instagram cursus (%s) - %s', 'woocommerce'), '{site_title}', '{order_number}', '{order_date}' ); // New subject text
return $email_obj->format_string( $subject_txt );
}
return $subject;
}
// Remove content before woocommerce_email_before_order_table hook
add_action('woocommerce_email_order_details', 'remove_content_before_order_table', 1, 4);
function remove_content_before_order_table($order, $sent_to_admin, $plain_text, $email) {
// Remove unwanted content here
remove_action('woocommerce_email_before_order_table', array($email, 'order_details'), 10);
}
// Customize email content for this custom status email notification
add_action( 'woocommerce_email_before_order_table', 'custom_content_for_customer_processing_order_email', 10, 4 );
function custom_content_for_customer_processing_order_email( $order, $sent_to_admin, $plain_text, $email ) {
// Check if it's the "Customer Processing Order" email triggered by 'awaiting-delivery' status
if ( $email->id === 'customer_processing_order' && $order->has_status( 'custom' ) ) {
echo '[h4]Bedankt voor het aanmelden voor de Instagram cursus.[/h4]';
echo 'Bij het aanmelden heb je je Instagram gebruikersnaam moeten invullen. Als je dit niet hebt gedaan, stuur deze dan zo snel als mogelijk naar ons toe als reactie op de deze e-mail, zodoende weten wij welke Instagram gebruiker wij moeten accepteren.
Je gaat een online cursus doen die volledig via Instagram te volgen is. Je krijgt één jaar lang toegang tot deze Instagram cursus.
Om de cursus te kunnen volgen vragen we je het volgende te doen:
[list]
[*]Volg onze cursuspagina op Instagram: [url=https://instagram.com/ehboviva.online?igshid=NzZlODBkYWE4Ng==]ehboviva.online[/url]
[*]Wij accepteren je verzoek binnen 48 uur
[*]Vanaf nu heb je één jaar lang toegang tot ons Instagram account en kan je dus op elk moment de cursus openen en doornemen
[/list]
Veel lees en kijk plezier, succes!
';
}
}
Сейчас мой код настроен так, что он отправляется вместе с обработкой почты. Но я хочу отправить только собственное электронное письмо. Или, возможно, измените получателя обрабатываемой почты на что-то другое, кроме почты клиента. Но когда я отключаю обработку почты, она тоже не отправляется. И когда я меняю почту получателя, он отправляет оба письма на этот адрес.
Что мне следует изменить?
P.S.
Я удалил много кода, иначе я не смог бы опубликовать это из-за обнаружения спама. Так что, если кто-то что-то пропустит, сообщите мне.
Я использую несколько пользовательских статусов заказов, которые успешно добавил в WooCommerce. Мне удалось настроить электронные письма, которые будут отправляться клиенту при заказе определенных типов продуктов. работает, Теперь я хочу изменить свой код, чтобы он отправлял только настроенные уведомления по электронной почте, а не почту, обрабатываемую WooCommerce по умолчанию. Вот рабочий пример моего кода: [code]// register a custom post status 'awaiting-delivery' for Orders add_action( 'init', 'register_custom_post_status', 20 ); function register_custom_post_status() { register_post_status( 'wc-custom', array( 'label' => _x( 'Instagram cursus', '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( 'Instagram cursus (%s)', 'Instagram cursus (%s)', 'woocommerce' ) ) ); }
// Adding custom status 'awaiting-delivery' to order edit pages dropdown add_filter( 'wc_order_statuses', 'custom_wc_order_statuses' ); function custom_wc_order_statuses( $order_statuses ) { $order_statuses['wc-custom'] = _x( 'Instagram cursus', 'Order status', 'woocommerce' ); return $order_statuses; }
// Adding custom status 'awaiting-delivery' to admin order list bulk dropdown 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_custom'] = __( 'Instagram cursus', 'woocommerce' ); return $actions; }
if ( in_array( $new_status, $custom_statuses ) ) { // Your settings here $email_key = 'WC_Email_Customer_Processing_Order'; // The email notification type
// Get specific WC_emails object $email_obj = WC()->mailer()->get_emails()[ $email_key ];
// Triggering the customized email $email_obj->trigger( $order_id ); } }
// Customize email heading for this custom status email notification add_filter( 'woocommerce_email_heading_customer_processing_order', 'email_heading_customer_awaiting_delivery_order', 10, 2 ); function email_heading_customer_awaiting_delivery_order( $heading, $order ){ if ($order->has_status('custom')) { $email_key = 'WC_Email_Customer_Processing_Order'; // The email notification type $email_obj = WC()->mailer()->get_emails()[$email_key]; // Get specific WC_emails object $heading_txt = __('Bevestigingsmail:','woocommerce'); // New heading text return $email_obj->format_string( $heading_txt ); } return $heading; }
// Customize email subject for this custom status email notification add_filter( 'woocommerce_email_subject_customer_processing_order', 'email_subject_customer_awaiting_delivery_order', 10, 2 ); function email_subject_customer_awaiting_delivery_order( $subject, $order ){ if ($order->has_status('custom')) { $email_key = 'WC_Email_Customer_Processing_Order'; // The email notification type $email_obj = WC()->mailer()->get_emails()[$email_key]; // Get specific WC_emails object $subject_txt = sprintf( __('[%s] Instagram cursus (%s) - %s', 'woocommerce'), '{site_title}', '{order_number}', '{order_date}' ); // New subject text return $email_obj->format_string( $subject_txt ); } return $subject; }
// Remove content before woocommerce_email_before_order_table hook add_action('woocommerce_email_order_details', 'remove_content_before_order_table', 1, 4);
function remove_content_before_order_table($order, $sent_to_admin, $plain_text, $email) { // Remove unwanted content here remove_action('woocommerce_email_before_order_table', array($email, 'order_details'), 10); }
// Customize email content for this custom status email notification add_action( 'woocommerce_email_before_order_table', 'custom_content_for_customer_processing_order_email', 10, 4 ); function custom_content_for_customer_processing_order_email( $order, $sent_to_admin, $plain_text, $email ) { // Check if it's the "Customer Processing Order" email triggered by 'awaiting-delivery' status if ( $email->id === 'customer_processing_order' && $order->has_status( 'custom' ) ) { echo '[h4]Bedankt voor het aanmelden voor de Instagram cursus.[/h4]'; echo 'Bij het aanmelden heb je je Instagram gebruikersnaam moeten invullen. Als je dit niet hebt gedaan, stuur deze dan zo snel als mogelijk naar ons toe als reactie op de deze e-mail, zodoende weten wij welke Instagram gebruiker wij moeten accepteren. Je gaat een online cursus doen die volledig via Instagram te volgen is. Je krijgt één jaar lang toegang tot deze Instagram cursus. Om de cursus te kunnen volgen vragen we je het volgende te doen: [list] [*]Volg onze cursuspagina op Instagram: [url=https://instagram.com/ehboviva.online?igshid=NzZlODBkYWE4Ng==]ehboviva.online[/url] [*]Wij accepteren je verzoek binnen 48 uur [*]Vanaf nu heb je één jaar lang toegang tot ons Instagram account en kan je dus op elk moment de cursus openen en doornemen [/list] Veel lees en kijk plezier, succes! '; } } [/code] Сейчас мой код настроен так, что он отправляется вместе с обработкой почты. Но я хочу отправить только собственное электронное письмо. Или, возможно, измените получателя обрабатываемой почты на что-то другое, кроме почты клиента. Но когда я отключаю обработку почты, она тоже не отправляется. И когда я меняю почту получателя, он отправляет оба письма на этот адрес. Что мне следует изменить? P.S. Я удалил много кода, иначе я не смог бы опубликовать это из-за обнаружения спама. Так что, если кто-то что-то пропустит, сообщите мне.
Я использую несколько пользовательских статусов заказов, которые успешно добавил в WooCommerce. Мне удалось настроить электронные письма, которые будут отправляться клиенту при заказе определенных типов продуктов. работает,
Теперь я хочу изменить...
Здесь я нашел хороший код для создания уникального статуса заказа с возможностью отправки электронного письма. Это работает хорошо, единственная проблема в том, что мой веб-сайт двуязычен (ro,hu), и все уникальные электронные письма о статусе...
Здесь я нашел хороший код для создания уникального статуса заказа с возможностью отправки электронного письма. Это работает хорошо, единственная проблема в том, что мой веб-сайт двуязычен (ro,hu), и все уникальные электронные письма о статусе...
Здесь я нашел хороший код для создания уникального статуса заказа с возможностью отправки электронного письма. Это работает хорошо, единственная проблема в том, что мой веб-сайт двуязычен (ro,hu), и все уникальные электронные письма о статусе...
Я пытаюсь реализовать аудиовызов в своем собственном приложении реагирования, используя SDK для вызова связи Azure. Когда приложение находится на переднем плане, И IncomingCallListener настроен ДО , инициируется вызов, все работает нормально. Но...