[2.2] Hide COD for virtual orders (no shipping) Closes #5369

This commit is contained in:
Mike Jolley 2014-04-24 16:37:31 +01:00
parent 67e29eade6
commit 76df3d6e2c
1 changed files with 8 additions and 2 deletions

View File

@ -104,6 +104,10 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
*/ */
public function is_available() { public function is_available() {
if ( ! WC()->cart->needs_shipping() ) {
return false;
}
if ( ! empty( $this->enable_for_methods ) ) { if ( ! empty( $this->enable_for_methods ) ) {
// Only apply if all packages are being shipped via local pickup // 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]; $check_method = $chosen_shipping_methods[0];
} }
if ( ! $check_method ) if ( ! $check_method ) {
return false; return false;
}
$found = false; $found = false;
@ -143,8 +148,9 @@ class WC_Gateway_COD extends WC_Payment_Gateway {
} }
} }
if ( ! $found ) if ( ! $found ) {
return false; return false;
}
} }
return parent::is_available(); return parent::is_available();