No need to count legacy separate

@claudiosmweb
This commit is contained in:
Mike Jolley 2016-05-26 12:54:14 +01:00
parent 1727d043a0
commit 14e89c69da
1 changed files with 3 additions and 11 deletions

View File

@ -1311,19 +1311,11 @@ function wc_get_shipping_method_count( $include_legacy = false ) {
$method_count = absint( $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_shipping_zone_methods" ) ); $method_count = absint( $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_shipping_zone_methods" ) );
if ( $include_legacy ) { if ( $include_legacy ) {
// WooCommerce legacy methods. // Count activated methods that don't support shipping zones.
$legacy_methods = array( 'flat_rate', 'free_shipping', 'international_delivery', 'local_delivery', 'local_pickup' );
foreach ( $legacy_methods as $method ) {
$options = get_option( 'woocommerce_' . $method . '_settings' );
if ( $options && isset( $options['enabled'] ) && 'yes' === $options['enabled'] ) {
$method_count++;
}
}
// Include only activated methods that don't support shipping zones.
$methods = WC()->shipping->get_shipping_methods(); $methods = WC()->shipping->get_shipping_methods();
foreach ( $methods as $method ) { foreach ( $methods as $method ) {
if ( ! $method->supports( 'shipping-zones' ) && isset( $method->enabled ) && 'yes' === $method->enabled ) { if ( isset( $method->enabled ) && 'yes' === $method->enabled && ! $method->supports( 'shipping-zones' ) ) {
$method_count++; $method_count++;
} }
} }