admin管理员组文章数量:1023187
I have implemented custom order status on-review
and now I need to send WooCommerce default on-hold email when switching order statuses from on-review
to on-hold
.
In order to do this, I have to add new woocommerce_order_status_on-review_to_on-hold_notification
action that will run trigger
method of WC_Email_Customer_On_Hold_Order
class.
It looks like there are no hooks nor filters to add this action to default WC_Email_Customer_On_Hold_Order
constructor and I have to override this class with custom one. To do so, I need to define my custom WC_Email_Customer_On_Hold_Order
class after WC_Email
class is defined, and before WC_Email_Customer_On_Hold_Order
class is defined.
The problem is that both these classes are included during init
method execution of WC_Emails
and there are no hooks between file inclusions.
Is there any other way to solve my problem?
I have implemented custom order status on-review
and now I need to send WooCommerce default on-hold email when switching order statuses from on-review
to on-hold
.
In order to do this, I have to add new woocommerce_order_status_on-review_to_on-hold_notification
action that will run trigger
method of WC_Email_Customer_On_Hold_Order
class.
It looks like there are no hooks nor filters to add this action to default WC_Email_Customer_On_Hold_Order
constructor and I have to override this class with custom one. To do so, I need to define my custom WC_Email_Customer_On_Hold_Order
class after WC_Email
class is defined, and before WC_Email_Customer_On_Hold_Order
class is defined.
The problem is that both these classes are included during init
method execution of WC_Emails
and there are no hooks between file inclusions.
Is there any other way to solve my problem?
Share Improve this question asked Jan 6, 2018 at 21:59 fakemetafakemeta 1116 bronze badges1 Answer
Reset to default 0Looks like I was overcomplicating things. This is the solution:
add_filter( 'woocommerce_email_classes', 'custom_woocommerce_email_classes', 10, 1 );
function custom_woocommerce_email_classes( $email_classes ) {
$email_classes[ 'WC_Email_Customer_On_Review_Request' ] = include_once 'includes/classes/class-wc-email-customer-on-review-request.php';
// Register custom trigger to send on-hold email when status is switched from on-review to on-hold.
add_action( 'woocommerce_order_status_on-review_to_on-hold_notification', [
$email_classes[ 'WC_Email_Customer_On_Hold_Order' ], 'trigger'
], 10, 2 );
return $email_classes;
}
I have implemented custom order status on-review
and now I need to send WooCommerce default on-hold email when switching order statuses from on-review
to on-hold
.
In order to do this, I have to add new woocommerce_order_status_on-review_to_on-hold_notification
action that will run trigger
method of WC_Email_Customer_On_Hold_Order
class.
It looks like there are no hooks nor filters to add this action to default WC_Email_Customer_On_Hold_Order
constructor and I have to override this class with custom one. To do so, I need to define my custom WC_Email_Customer_On_Hold_Order
class after WC_Email
class is defined, and before WC_Email_Customer_On_Hold_Order
class is defined.
The problem is that both these classes are included during init
method execution of WC_Emails
and there are no hooks between file inclusions.
Is there any other way to solve my problem?
I have implemented custom order status on-review
and now I need to send WooCommerce default on-hold email when switching order statuses from on-review
to on-hold
.
In order to do this, I have to add new woocommerce_order_status_on-review_to_on-hold_notification
action that will run trigger
method of WC_Email_Customer_On_Hold_Order
class.
It looks like there are no hooks nor filters to add this action to default WC_Email_Customer_On_Hold_Order
constructor and I have to override this class with custom one. To do so, I need to define my custom WC_Email_Customer_On_Hold_Order
class after WC_Email
class is defined, and before WC_Email_Customer_On_Hold_Order
class is defined.
The problem is that both these classes are included during init
method execution of WC_Emails
and there are no hooks between file inclusions.
Is there any other way to solve my problem?
Share Improve this question asked Jan 6, 2018 at 21:59 fakemetafakemeta 1116 bronze badges1 Answer
Reset to default 0Looks like I was overcomplicating things. This is the solution:
add_filter( 'woocommerce_email_classes', 'custom_woocommerce_email_classes', 10, 1 );
function custom_woocommerce_email_classes( $email_classes ) {
$email_classes[ 'WC_Email_Customer_On_Review_Request' ] = include_once 'includes/classes/class-wc-email-customer-on-review-request.php';
// Register custom trigger to send on-hold email when status is switched from on-review to on-hold.
add_action( 'woocommerce_order_status_on-review_to_on-hold_notification', [
$email_classes[ 'WC_Email_Customer_On_Hold_Order' ], 'trigger'
], 10, 2 );
return $email_classes;
}
本文标签: customizationSend default WooCommerce email when switching from custom order status
版权声明:本文标题:customization - Send default WooCommerce email when switching from custom order status 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745598959a2158340.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论