From 76df3d6e2c28ed2aa12dc8c54eaa6e562c4dc84d Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 24 Apr 2014 16:37:31 +0100 Subject: [PATCH] [2.2] Hide COD for virtual orders (no shipping) Closes #5369 --- includes/gateways/cod/class-wc-gateway-cod.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/includes/gateways/cod/class-wc-gateway-cod.php b/includes/gateways/cod/class-wc-gateway-cod.php index 9509a7682bb..8581ea3e1e9 100644 --- a/includes/gateways/cod/class-wc-gateway-cod.php +++ b/includes/gateways/cod/class-wc-gateway-cod.php @@ -104,6 +104,10 @@ class WC_Gateway_COD extends WC_Payment_Gateway { */ public function is_available() { + if ( ! WC()->cart->needs_shipping() ) { + return false; + } + if ( ! empty( $this->enable_for_methods ) ) { // Only apply if all packages are being shipped via local pickup @@ -131,8 +135,9 @@ class WC_Gateway_COD extends WC_Payment_Gateway { $check_method = $chosen_shipping_methods[0]; } - if ( ! $check_method ) + if ( ! $check_method ) { return false; + } $found = false; @@ -143,8 +148,9 @@ class WC_Gateway_COD extends WC_Payment_Gateway { } } - if ( ! $found ) + if ( ! $found ) { return false; + } } return parent::is_available();