I found a custom solution.
I just find class-wc-gateway-cod.php in /plugin/woocommerce/classes/gateways directory.
This class work this “payment in cash”.
When find function process_payment
And if in it you see $order->update_status('on-hold'
it is mean ,that this function works when you get a new order.
old function:
function process_payment ($order_id) {
global $woocommerce;
$order = new WC_Order( $order_id );
// Mark as on-hold (we're awaiting the cheque)
$order->update_status('on-hold', __( 'Payment to be made upon delivery.', 'woocommerce' ));
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
$woocommerce->cart->empty_cart();
// Return thankyou redirect
return array(
'result' => 'success',
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks'))))
);
}
New function:
function process_payment ($order_id) {
global $woocommerce;
$order = new WC_Order( $order_id );
// Mark as on-hold (we're awaiting the cheque)
$order->update_status('on-hold', __( 'Payment to be made upon delivery.', 'woocommerce' ));
$mailer = $woocommerce->mailer();
$mailer->emails['WC_Email_New_Order']->trigger($order_id);
// Reduce stock levels
$order->reduce_order_stock();
// Remove cart
$woocommerce->cart->empty_cart();
// Return thankyou redirect
return array(
'result' => 'success',
'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks'))))
);
}
where ‘WC_Email_New_Order’ it is a type of email.