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

@ -87,28 +87,29 @@ class WC_Local_Pickup extends WC_Shipping_Method {
</table> <?php
}
function is_available( $package ) {
global $woocommerce;
if ($this->enabled=="no") return false;
function is_available( $package ) {
global $woocommerce;
$is_available = true;
if ( $this->enabled == 'no' ) {
$is_available = false;
} else {
$ship_to_countries = '';
if ( $this->availability == 'specific' ) {
$ship_to_countries = $this->countries;
} elseif ( get_option( 'woocommerce_allowed_countries' ) == 'specific' ) {
$ship_to_countries = get_option( 'woocommerce_specific_allowed_countries' );
}
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', $is_available, $package );
}
$ship_to_countries = '';
if ($this->availability == 'specific') :
$ship_to_countries = $this->countries;
else :
if (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;
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', true );
}
}
function add_local_pickup_method($methods) { $methods[] = 'WC_Local_Pickup'; return $methods; }