Guest User

Untitled

a guest
Feb 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. add_filter('woocommerce_available_payment_gateways','filter_gateways',1);
  2.  
  3. function filter_gateways($gateways){
  4. global $woocommerce;
  5. $inarray = false;
  6. $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 //
  7. foreach ($woocommerce->cart->cart_contents as $key => $values ) {//enumerate over all cart contents
  8. if(in_array($values['product_id'],$specialItem)){//if special item is in it
  9. $inarray = true;//set inarray to true
  10. }
  11. }
  12.  
  13. if($inarray) {//product is in the cart
  14. unset($gateways['bacs'],$gateways['gpgcheckout']);
  15. } else { unset($gateways['other_payment']);}
  16. return $gateways;}
Add Comment
Please, Sign In to add comment