Don't set them for unexistent rates.

This commit is contained in:
George Stephanis 2015-08-07 17:06:50 -04:00
parent 5736d66a92
commit bba6f80d9d
1 changed files with 5 additions and 0 deletions

View File

@ -13,6 +13,11 @@ $rates = array_combine( wp_list_pluck( $rates, 'tax_rate_id' ), $rates );
// Drop the locations into the rates array. // Drop the locations into the rates array.
foreach ( $locations as $location ) { foreach ( $locations as $location ) {
// Don't set them for unexistent rates.
if ( ! isset( $rates[ $location->tax_rate_id ] ) ) {
continue;
}
// If the rate exists, initialize the array before appending to it.
if ( ! isset( $rates[ $location->tax_rate_id ]->{$location->location_type} ) ) { if ( ! isset( $rates[ $location->tax_rate_id ]->{$location->location_type} ) ) {
$rates[ $location->tax_rate_id ]->{$location->location_type} = array(); $rates[ $location->tax_rate_id ]->{$location->location_type} = array();
} }