Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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