Skip to content

Instantly share code, notes, and snippets.

@pippinsplugins
Created July 11, 2014 13:22
Show Gist options
  • Save pippinsplugins/d498bb26d0723ae99f0a to your computer and use it in GitHub Desktop.
Save pippinsplugins/d498bb26d0723ae99f0a to your computer and use it in GitHub Desktop.
Disable the Stripe payment gateway when a specific Download ID is in the cart
<?php
function pw_edd_maybe_disable_stripe( $gateways ) {
$disable = false;
$cart_items = edd_get_cart_contents();
if( $cart_items ) {
foreach( $cart_items as $item ) {
// Disable Stripe if the Download with an ID of 234 is in the cart
if( 234 == $item['id'] ) {
$disable = true;
break;
}
}
}
if( $disable ) {
unset( $gateways[ 'stripe' ] );
}
return $gateways;
}
add_filter( 'edd_enabled_payment_gateways', 'pw_edd_maybe_disable_stripe' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment