Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce Authorize.net CIM: Adjust authorize-only transaction order status
<?php
function sv_wc_auth_net_cim_tweak_held_order_status( $order_status, $order, $response ) {
if ( 'on-hold' === $order_status && $response instanceof SV_WC_Payment_Gateway_API_Response && $response->transaction_approved() ) {
$order_status = 'processing';
}
return $order_status;
}
add_filter( 'wc_payment_gateway_authorize_net_cim_credit_card_held_order_status', 'sv_wc_auth_net_cim_tweak_held_order_status', 10, 3 );
@wvega

This comment has been minimized.

Copy link

@wvega wvega commented Jul 16, 2019

Thank you for this snippet @maxrice, I found it on https://docs.woocommerce.com/document/authorize-net-cim/#section-27.

I noticed that the SV_WC_Payment_Gateway_API_Response interface is under the Plugin Framework namespace, at least in Authorize.Net 3.0.5. The instanceof verification is currently failing because that. I'm guessing that we need to use the fully qualified name of the interface, but I also I believe that the Plugin Framework namespace changes frequently between updates, so that makes it a little inconvenient to keep the snippet up to date.

As an alternative, I replaced that part of the condition with $response instanceof WC_Authorize_Net_CIM_API_Transaction_Response. That fixed the snippet on my end.

@maxrice

This comment has been minimized.

Copy link
Owner Author

@maxrice maxrice commented Jul 17, 2019

@wvega that's a good improvement, thanks!

@bryanearl907

This comment has been minimized.

Copy link

@bryanearl907 bryanearl907 commented Oct 19, 2020

@wvega and @maxrice - Can either of you please tell me where exactly to use this snippet? I am trying to force my auth.net to make the status "processing" instead of "on hold", when "authorization only" is used in the payment plugin. I placed this into my child theme's functions.php, but it does not appear to be working. Any input is appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment