Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_Tax::sort_rates_callback( object $rate1, object $rate2 )
Does the sort comparison. Compares (in this order): – Priority – Country – State – Number of postcodes – Number of cities – ID
Description Description
Parameters Parameters
- $rate1
-
(Required) First rate to compare.
- $rate2
-
(Required) Second rate to compare.
Return Return
(int)
Source Source
File: includes/class-wc-tax.php
private static function sort_rates_callback( $rate1, $rate2 ) { if ( $rate1->tax_rate_priority !== $rate2->tax_rate_priority ) { return $rate1->tax_rate_priority < $rate2->tax_rate_priority ? -1 : 1; // ASC. } if ( $rate1->tax_rate_country !== $rate2->tax_rate_country ) { if ( '' === $rate1->tax_rate_country ) { return 1; } if ( '' === $rate2->tax_rate_country ) { return -1; } return strcmp( $rate1->tax_rate_country, $rate2->tax_rate_country ) > 0 ? 1 : -1; } if ( $rate1->tax_rate_state !== $rate2->tax_rate_state ) { if ( '' === $rate1->tax_rate_state ) { return 1; } if ( '' === $rate2->tax_rate_state ) { return -1; } return strcmp( $rate1->tax_rate_state, $rate2->tax_rate_state ) > 0 ? 1 : -1; } if ( isset( $rate1->postcode_count, $rate2->postcode_count ) && $rate1->postcode_count !== $rate2->postcode_count ) { return $rate1->postcode_count < $rate2->postcode_count ? 1 : -1; } if ( isset( $rate1->city_count, $rate2->city_count ) && $rate1->city_count !== $rate2->city_count ) { return $rate1->city_count < $rate2->city_count ? 1 : -1; } return $rate1->tax_rate_id < $rate2->tax_rate_id ? -1 : 1; }