Skip to content

Instantly share code, notes, and snippets.

@NickGreen
Last active February 27, 2019 00:29
Show Gist options
  • Save NickGreen/90c733c1fcebd612d7961a3bc79ef16f to your computer and use it in GitHub Desktop.
Save NickGreen/90c733c1fcebd612d7961a3bc79ef16f to your computer and use it in GitHub Desktop.
Set Auth.net to 'Authorize only' if there are no subscription products in the cart
<?php
// note: this would require the store settings to be set to "capture" to begin with
function wc_authorize_net_cim_credit_card_change_transaction_type_no_subs( $settings ) {
if ( method_exists( 'WC_Subscriptions_Cart' , 'cart_contains_subscription' ) ) {
if ( ! WC_Subscriptions_Cart::cart_contains_subscription() ) {
$settings['transaction_type'] = 'authorization';
}
}
return $settings;
}
add_filter( 'option_woocommerce_authorize_net_cim_credit_card_settings', 'wc_authorize_net_cim_credit_card_change_transaction_type_no_subs' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment