How to set Pending Payment Direct Bank Transfer - Bacs Woocommerce
By default when user change payment method with Direct Bank Transfer (bacs), order status set to ‘on-hold’, but in the some case you want to set Pending Payment ‘pending’, you can add filter in functions.php on your template like bellow
add_action( 'woocommerce_thankyou', 'bacs_order_payment_processing_order_status', 10, 1 );
function bacs_order_payment_processing_order_status( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = new WC_Order( $order_id );
if ( ( get_post_meta($order->id, '_payment_method', true) == 'bacs' ) && ('on-hold' == $order->status || 'pending' == $order->status) ) {
$order->update_status('pending');
} else {
return;
}
}
in the code above I use filter ‘woocommerce_thankyou’, if this code above too long, I have alternative :
add_action('woocommerce_thankyou', function($order_id) {
if (!$order_id) return;
$order = wc_get_order($order_id);
if ($order->get_payment_method() === 'bacs' && in_array($order->get_status(), ['on-hold', 'pending'])) {
$order->update_status('pending');
}
});
0 Response to "How to set Pending Payment Direct Bank Transfer - Bacs Woocommerce"
Post a Comment
Komentar yang Anda kirim akan terlebih dahulu di moderasi oleh Admin