0

使用下面的代码,我可以在订单完成后成功地将自定义订单注释添加到订阅续订订单中。

但是,我想修改它以将注释添加到Subscription Notes而不是Order Notes。我认为订阅说明使用与而不是相同的add_order_note功能。但是我试图让 $subscription 变量在下面的代码中工作没有成功。$subscription->add_order_note$order->add_order_note

// Add box contents (product excerpt) as order note for subscriptions

add_action( 'woocommerce_email_before_order_table', 'custom_action_on_completed_customer_email_notification', 10, 4 );
function custom_action_on_completed_customer_email_notification( $order, $sent_to_admin, $plain_text, $email ) {


if( 'customer_completed_renewal_order' == $email->id ){ // for processing order status customer notification…

$product_id = '';

foreach ($order->get_items() as $item_id => $item_values) {
    $product_id = $item_values['product_id'];

    break; // (optional) stop loop to first item
}

// The text for the note

$note = get_the_excerpt($product_id);

// Add the note
$order->add_order_note( $note, $is_customer_note = 1 );

// Save the data
$order->save(); 

}

}

您知道我需要添加/更改什么才能将此添加到订阅注释而不是订单注释吗?

4

0 回答 0