You can use the filters provided by WooCommerce to accomplish what you want.
Example:
add_filter('woocommerce_available_payment_gateways', function($gateways){
if(is_checkout() && WC()->cart){
foreach(WC()->cart->get_cart() as $values){
if(isset($values['data'])){
if($values['data']->get_id() === 79){
unset($gateways['stripe_ach']);
break;
}
}
}
}
return $gateways;
});
You will need to replace “79” with your own product ID.
Thread Starter
gbever
(@gbever)
Thank you so much for the super fast response. This code seems to work perfectly but it does the opposite of what i need. I only want to show ACH.
I assume id only need to change:
$gateways[‘stripe_ach’]
but Im unsure of what to set that to. Tried a number of variations including cc, credit_card etc.
-
This reply was modified 2 years, 2 months ago by
gbever.
Thread Starter
gbever
(@gbever)
Via experimentation, I was able to figure out that your answer works perfectly with unset($gateways[‘stripe’]);
Marking this closed and thanks for the great support.