Hey @bbender75
Hope you are doing well!
this is a snippet code that you need to add to your site so you can handle your orders with the “Processing” status instead of the “On hold” one.
add_action(
'init',
function() {
if ( ! class_exists( 'WC_Bluesnap_Order_Handler' ) ) {
return;
}
$order_handler = WC_Bluesnap_Order_Handler::get_instance();
remove_action( 'woocommerce_order_status_on-hold_to_processing', array( $order_handler, 'capture_payment' ) );
remove_action( 'woocommerce_order_status_on-hold_to_completed', array( $order_handler, 'capture_payment' ) );
remove_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $order_handler, 'cancel_payment' ) );
remove_action( 'woocommerce_order_status_on-hold_to_refunded', array( $order_handler, 'cancel_payment' ) );
add_action( 'woocommerce_order_status_processing_to_completed', array( $order_handler, 'capture_payment' ) );
add_action( 'woocommerce_order_status_processing_to_cancelled', array( $order_handler, 'cancel_payment' ) );
add_action( 'woocommerce_order_status_processing_to_refunded', array( $order_handler, 'cancel_payment' ) );
}
);
function blackstone_bluesnap_update_order_processing( $order, $payment_method_data, $transaction ) {
if (
'AUTH_AND_CAPTURE' !== $transaction['cardTransactionType'] &&
'no' === $order->get_meta( '_bluesnap_charge_captured', true ) &&
'on-hold' === $order->get_status()
) {
$order->update_status( 'processing', sprintf( __( 'Bluesnap charge authorized (Charge ID: %s). Process order to take payment, or cancel to remove the pre-authorization.', 'woocommerce-bluesnap-gateway' ), $transaction['transactionId'] ) );
}
}
add_action( 'wc_gateway_bluesnap_new_card_payment_success', 'blackstone_bluesnap_update_order_processing', 10, 3 );
add_action( 'wc_gateway_bluesnap_new_ach_payment_success', 'blackstone_bluesnap_update_order_processing', 10, 3 );
add_action( 'wc_gateway_bluesnap_token_payment_success', 'blackstone_bluesnap_update_order_processing', 10, 3 );
Please first test this snippet on your staging site before adding it to your live site.
Best,
Christian