Merge pull request #1116 from GeertDD/local_pickup_is_available

Applied woocommerce filter to all return values of the is_available method
This commit is contained in:
Mike Jolley 2012-06-05 05:35:42 -07:00
commit 1f68bf809d
1 changed files with 22 additions and 21 deletions

View File

@ -89,24 +89,25 @@ class WC_Local_Pickup extends WC_Shipping_Method {
function is_available( $package ) {
global $woocommerce;
$is_available = true;
if ($this->enabled=="no") return false;
if ( $this->enabled == 'no' ) {
$is_available = false;
} else {
$ship_to_countries = '';
if ($this->availability == 'specific') :
if ( $this->availability == 'specific' ) {
$ship_to_countries = $this->countries;
else :
if (get_option('woocommerce_allowed_countries')=='specific') :
} elseif ( get_option( 'woocommerce_allowed_countries' ) == 'specific' ) {
$ship_to_countries = get_option( 'woocommerce_specific_allowed_countries' );
endif;
endif;
}
if (is_array($ship_to_countries))
if ( ! in_array( $package['destination']['country'], $ship_to_countries ) )
return false;
if ( is_array( $ship_to_countries ) && ! in_array( $package['destination']['country'], $ship_to_countries ) ) {
$is_available = false;
}
}
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', true );
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available, $package );
}
}