Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('woocommerce_available_payment_gateways','filter_gateways',1);
- function filter_gateways($gateways){
- global $woocommerce;
- $inarray = false;
- $specialItem=array(492496,492551,492563,492583,492589,492606,492623,492636,492690,492702,492708,492832,492840,492887,492903,492914,492926,492939,493010,493019,493027,493293,493460,493467);//array contains ids of many products //
- foreach ($woocommerce->cart->cart_contents as $key => $values ) {//enumerate over all cart contents
- if(in_array($values['product_id'],$specialItem)){//if special item is in it
- $inarray = true;//set inarray to true
- }
- }
- if($inarray) {//product is in the cart
- unset($gateways['bacs'],$gateways['gpgcheckout']);
- } else { unset($gateways['other_payment']);}
- return $gateways;}
Add Comment
Please, Sign In to add comment