我在我的WooCommerce安装中创建了一个名为Quote的自定义订单状态.
/*
* Change order status on new orders depending on order contents:
* If any product in the order is availble for quote, return 'quote' status.
* Otherwise the order status will be set to processing.
*/
add_filter ('woocommerce_payment_complete_order_status', 'change_status_to_quote_if_applicable', 10, 2);
function change_status_to_quote_if_applicable($order_status, $order_id) {
$order = new WC_Order($order_id);
$items = $order->get_items();
foreach ($items as $item) {
$product = get_product($item['product_id']);
if(product_available_for_quote($product)){
return 'quote';
}
}
return $order_status;
}
Run Code Online (Sandbox Code Playgroud)
现在,我想在收到已收到状态报价的订单时收到一封电子邮件.我根据这篇有用的文章创建了一个插件:http://www.skyverge.com/blog/how-to-add-a-custom-woocommerce-email/
我的插件基本上都是从文章中复制过来的,我刚刚更改了电子邮件的内容.我想改变的是触发电子邮件的原因.
文章中的插件有:
// Trigger on new …Run Code Online (Sandbox Code Playgroud) 我使用此代码创建了一些自定义订单状态
register_post_status( 'wc-arrival-shipment', array(
'label' => 'Shipped but not paid',
'public' => false,
'show_in_admin_status_list' => true,
'show_in_admin_all_list' => true,
'exclude_from_search' => false,
'label_count' => _n_noop( 'Shipped but not paid<span class="count">(%s)</span>', 'Shipped but not paid <span class="count">(%s)</span>' )
) );
Run Code Online (Sandbox Code Playgroud)
除所有订单清单外,其他一切运行良好。它会显示正确的计数all(3),但是在清单中您只会看到1个订单,并且不会显示已更新为新的自定义订单状态的所有其他2个订单。仅显示1个订单,仅保留