Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('woocommerce_available_payment_gateways', 'unsetting_payment_gateway', 10, 1);
- function unsetting_payment_gateway( $available_gateways ) {
- // HERE Define the limit of quantity item
- $qty_limit = 1;
- $limit_reached = false;
- // Iterating through each items in cart
- if ( WC()->cart->get_cart_contents_count() > $qty_limit ){
- $limit_reached = true;
- }
- if($limit_reached){
- // HERE set the slug of your payment method
- unset($available_gateways['cod']);
- }
- return $available_gateways;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement