mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
13 lines
567 B
Text
13 lines
567 B
Text
add_filter( 'woocommerce_checkout_order_processed', 'change_cod_order_status_to_on_hold', 10, 3 );
|
|
|
|
function change_cod_order_status_to_on_hold( $order_id, $posted_data, $order ) {
|
|
if ( ! $order instanceof WC_Order ) {
|
|
return;
|
|
}
|
|
|
|
// Check if payment method is Cash on Delivery
|
|
if ( $order->get_payment_method() === 'cod' && $order->get_status() === 'processing' ) {
|
|
// Set order status to 'on-hold'
|
|
$order->update_status( 'on-hold', __( 'Order status changed to on-hold for COD payment method.', 'your-textdomain' ) );
|
|
}
|
|
}
|