更新时间:2023-11-30 16:40:52
无法在一个动作中运行一个动作.
Running an action within an action isn't possible, I believe.
如果您查看此操作的代码,则可以访问以下内容:
If you check the code for this action, you have access to the following:
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email );
因此,您可能无法挂接到woocommerce_checkout_subscription_created
,而只能使用woocommerce_email_before_order_table
.
Therefore, you could perhaps NOT hook into woocommerce_checkout_subscription_created
and only use woocommerce_email_before_order_table
.
然后您可以查询$order
是否为订阅,然后相应地修改输出.
You could then query whether or not the $order
is a subscription and then modify the output accordingly.
add_action( 'woocommerce_email_before_order_table', function($order, $sent_to_admin, $plain_text, $email) {
if ( function_exists( 'wcs_order_contains_subscription' ) ) {
if ( wcs_order_contains_subscription( $order->ID ) ) {
// Do what you need to do
}
}
}, 10, 4 );