Merge pull request #6641 from coenjacobs/filter-empty-rate-code

Allow to filter empty tax rate code
This commit is contained in:
Mike Jolley 2014-10-29 10:04:34 +00:00
commit bcaf0e0779
1 changed files with 10 additions and 9 deletions

View File

@ -576,17 +576,18 @@ class WC_Tax {
$rate = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %s", $key ) );
}
if ( ! $rate ) {
return '';
$code_string = '';
if ( null !== $rate ) {
$code = array();
$code[] = $rate->tax_rate_country;
$code[] = $rate->tax_rate_state;
$code[] = $rate->tax_rate_name ? $rate->tax_rate_name : 'TAX';
$code[] = absint( $rate->tax_rate_priority );
$code_string = strtoupper( implode( '-', array_filter( $code ) ) );
}
$code = array();
$code[] = $rate->tax_rate_country;
$code[] = $rate->tax_rate_state;
$code[] = $rate->tax_rate_name ? $rate->tax_rate_name : 'TAX';
$code[] = absint( $rate->tax_rate_priority );
return apply_filters( 'woocommerce_rate_code', strtoupper( implode( '-', array_filter( $code ) ) ), $key );
return apply_filters( 'woocommerce_rate_code', $code_string, $key );
}
/**