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:
commit
1f68bf809d
|
@ -89,24 +89,25 @@ class WC_Local_Pickup extends WC_Shipping_Method {
|
||||||
|
|
||||||
function is_available( $package ) {
|
function is_available( $package ) {
|
||||||
global $woocommerce;
|
global $woocommerce;
|
||||||
|
$is_available = true;
|
||||||
|
|
||||||
if ($this->enabled=="no") return false;
|
if ( $this->enabled == 'no' ) {
|
||||||
|
$is_available = false;
|
||||||
|
} else {
|
||||||
$ship_to_countries = '';
|
$ship_to_countries = '';
|
||||||
|
|
||||||
if ($this->availability == 'specific') :
|
if ( $this->availability == 'specific' ) {
|
||||||
$ship_to_countries = $this->countries;
|
$ship_to_countries = $this->countries;
|
||||||
else :
|
} elseif ( get_option( 'woocommerce_allowed_countries' ) == 'specific' ) {
|
||||||
if (get_option('woocommerce_allowed_countries')=='specific') :
|
|
||||||
$ship_to_countries = get_option( 'woocommerce_specific_allowed_countries' );
|
$ship_to_countries = get_option( 'woocommerce_specific_allowed_countries' );
|
||||||
endif;
|
}
|
||||||
endif;
|
|
||||||
|
|
||||||
if (is_array($ship_to_countries))
|
if ( is_array( $ship_to_countries ) && ! in_array( $package['destination']['country'], $ship_to_countries ) ) {
|
||||||
if ( ! in_array( $package['destination']['country'], $ship_to_countries ) )
|
$is_available = false;
|
||||||
return false;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', true );
|
return apply_filters( 'woocommerce_shipping_' . $this->id . '_is_available', $is_available, $package );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue