Does anyone have advice on how to do a combo – restrict some gateways for some products and others for others? I can’t seem to get the proper function down. Here’s what I have, and what I want to add below.
add_filter(‘woocommerce_available_payment_gateways’,’filter_gateways’,1);
function filter_gateways($gateways){
global $woocommerce;
foreach ($woocommerce->cart->cart_contents as $key => $values ) {
//store product id’s in array
$highpriceditems = array(24,55);
if(in_array($values[‘product_id’],$highpriceditems)){
unset($gateways[‘mijireh_checkout’]);
unset($gateways[‘cheque’]);
unset($gateways[‘bitpay’]);
unset($gateways[‘wepay’]);
break;
}}
return $gateways;
}
*****
For products 24 and 55, those 4 gateways do NOT show up at checkout. this is good.
But, I can’t figure out how to do something different for product 75. I want to do the following:
unset($gateways[‘mijireh_checkout’]);
unset($gateways[‘paypal’]);
FYI – I’m not worried about all those products in the cart at the same time, because the first 2 are subscription products, they can’t be in there together anyway.