Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. add_filter('woocommerce_available_payment_gateways', 'unsetting_payment_gateway', 10, 1);
  2. function unsetting_payment_gateway( $available_gateways ) {
  3.  
  4. // HERE Define the limit of quantity item
  5. $qty_limit = 1;
  6. $limit_reached = false;
  7.  
  8. // Iterating through each items in cart
  9.  
  10. if ( WC()->cart->get_cart_contents_count() > $qty_limit ){
  11. $limit_reached = true;
  12. }
  13.  
  14. if($limit_reached){
  15. // HERE set the slug of your payment method
  16. unset($available_gateways['cod']);
  17. }
  18. return $available_gateways;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement