From 61e96b0a8b05a7f1fbea2e5a885867137c7dd721 Mon Sep 17 00:00:00 2001 From: claudiosmweb Date: Fri, 10 Oct 2014 23:01:19 -0300 Subject: [PATCH] Prevent warnings in WC_Shipping_Method::is_available() when exclude countries --- includes/abstracts/abstract-wc-shipping-method.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/abstracts/abstract-wc-shipping-method.php b/includes/abstracts/abstract-wc-shipping-method.php index 3c50e376f5f..c8878eeccd3 100644 --- a/includes/abstracts/abstract-wc-shipping-method.php +++ b/includes/abstracts/abstract-wc-shipping-method.php @@ -173,16 +173,17 @@ abstract class WC_Shipping_Method extends WC_Settings_API { } // Country availability + $countries = is_array( $this->countries ) ? $this->countries : array(); + switch ( $this->availability ) { case 'specific' : case 'including' : - $countries = is_array( $this->countries ) ? $this->countries : array(); $ship_to_countries = array_intersect( $countries, array_keys( WC()->countries->get_shipping_countries() ) ); break; case 'excluding' : - $ship_to_countries = array_diff( array_keys( WC()->countries->get_shipping_countries() ), $this->countries ); + $ship_to_countries = array_diff( array_keys( WC()->countries->get_shipping_countries() ), $countries ); break; default :